Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Mail modules on W2K

by Zo (Scribe)
on Feb 07, 2002 at 16:16 UTC ( #143904=perlquestion: print w/replies, xml ) Need Help??

Zo has asked for the wisdom of the Perl Monks concerning the following question:

Good Day all,
I've been working on this issue for some time now and have gone through CPAN, both the Oreilly Perl Cookbook and Nutshell books that I have, and I have gone so far as to email directly Mr. Mark Overmeer (mailtools-1.42) for some advice. He's not too familiar with MSdos .. just familiar w/UNIX so he wasn't able to help me out too much. (Thank you sincerely again if you read this).

I don't know if I loaded the modules correctly on my Windows2000 or what... I keep getting errors such as
Can't locate object method "new" via package "Mail::Mailer" (perhaps you forgot to load?"
Now I know I didn't forget to load it, but maybe I'm missing something here.
Any help/advice from someone who is using the mail modules on windows? I would even try to use SMTP (from reading in the books, but is seems that mail::mailer would be easier).

thank you all in advance

Replies are listed 'Best First'.
Re: Mail modules on W2K
by simon.proctor (Vicar) on Feb 07, 2002 at 16:39 UTC
    I have managed to use Mail::Mailer sucessfully on WinME, Win2k and on NT4. So it boils down to:

    1. Where did you get the package from? Did you install the ActiveState version?
    2. Are you using ActiveState Perl? If so you can grab the ppm version.
    3. Have you installed it in a non-standard place. You'll need to "use lib" if so.
    4. If it is in a non-standard place, where did you put it?

    Also, can you post your test script so we can check that too?
    Update:Someone further down this post mentioned that theres no archive from Activestate, well here it is.
(RhetTbull) Re: Mail modules on W2K
by RhetTbull (Curate) on Feb 07, 2002 at 16:36 UTC
    I'm not sure what mail modules are available for Win32 but I routinely use something like this for sending email via Microsoft Outlook. It works well enough if all you need to do is send email from the account on your Win2K box. You'll need Win32::OLE.
    sub send_outlook_mail { #use OLE and Outlook to send an email message my $to = shift || croak "required parameter (to address) missing"; my $subject = shift; $subject = "" if not defined $subject; my $body = shift; $body = "" if not defined $body; my $cc = shift; $cc = "" if not defined $cc; #get new Outlook instance my $mail = new Win32::OLE('Outlook.Application'); croak "Unable to start Outlook instance: $!" if !defined $mail; my $item = $mail->CreateItem(0); croak "Unable to create mail item: $!" if !defined $item; $item->{'To'} = $to; $item->{'CC'} = $cc; $item->{'Subject'} = $subject; $item->{'Body'} = $body; #rest of args are file attachments foreach my $attach (@ARGV) { # print STDERR "File attachment: $attach\n"; #make sure the attachment is really there croak "Missing attachment $attach: $!" if !-e $attach; my $attachments = $item->Attachments(); $attachments->Add($attach); } #send it $item->Send(); my $error = Win32::OLE->LastError(); carp "Win32::OLE error: $error" if $error; } #sub send_outlook_mail
Re: Mail modules on W2K
by gav^ (Curate) on Feb 07, 2002 at 16:42 UTC

    I've not used Mail::Mailer on NT but Mail::Sendmail works a treat (just make sure you set your smtp server). If you have Activestate's perl you can install it with PPM (just type ppm install Mail::Sendmail at a dos prompt). An example:

    use Mail::Sendmail; sendmail(To => $to, From => $from, Message => $msg, Subject => $subject, smtp => 'localhost') || die "Couldn't send email";


Re: Mail modules on W2K
by perrin (Chancellor) on Feb 07, 2002 at 16:45 UTC
    It's not possible to determine your mistake without seeing your code. However, I can vouch for Mail::Sendmail, which I am using on Win2K with good results. It looks like this:
    use Mail::Sendmail; my %mail = ( SMTP => $SMTP_SERVER, To => $EMAIL_TO, Cc => '', From => $EMAIL_FROM, Subject => 'testing', Message => $message, ); sendmail(%mail) or die $Mail::Sendmail::error;
Re: Mail modules on W2K
by Biker (Priest) on Feb 07, 2002 at 16:32 UTC

    The module is most likely not installed in the appropriate directory.

    Read this node. It's for another module, but the problem is basically the same.

    "Livet är hårt" sa bonden.
    "Grymt" sa grisen...

Re: Mail modules on W2K
by gellyfish (Monsignor) on Feb 07, 2002 at 16:52 UTC

    Mail::Mailer is not available via PPM for ActivePerl so I guess that you must have either downloaded the tarball of MailTools and either install it manually (if you have nmake) or copied the files to the appropriate place - if you did that you will also need to have copied the,, and into (if you have a similar setup as I do) C:\Perl\site\lib\Mail\Mailer. The Mail::Mailer::smtp (which you will almost certainly be using on windows as neither 'mail' or 'sendmail' will work :) also requires Mail::Utils but this is part of MailTools - unfortunately this does not work on Windows because it uses getpwuid which is not available there.

    I would suggest that you use Net::SMTP until I have written the patch for MailTools that will overcome this problem.

    (Sorry this is a bit patchy - I was going through the steps as I was typing :)

    Update: I sent a patch to Mark Overmeer so that Mail::Mailer will work on Windows - as :

    --- Thu Feb 7 18:36:47 2002 +++ Thu Feb 7 19:08:20 2002 @@ -226,7 +226,7 @@ $mailaddress ||= $ENV{USER} || $ENV{LOGNAME} || - getpwuid($>) || + eval { local $SIG{__DIE__}; scalar getpwuid($>); + } || "postmaster"; ##


Re: Mail modules on W2K
by beebware (Pilgrim) on Feb 07, 2002 at 20:57 UTC

    For sending mail from multi-platforms (such as using a Windows 2000 Professional machine for testing, moving the code to Windows 2000 Advanced Server and then to a Linux box), I tend to use Mime::Lite. It's available via Activestate PPM (so it's extremely easy to install on a Windows machine), you can configure it to either Sendmail (if you've got it installed) or connect directly to your mail server, you can add 'attachments' and it's got plenty of example code for you to examine and try - one of the simplist ways that I use it is:

    use Mime::Lite MIME::Lite->send('smtp', $mail_server_name_or_ip_address, TimeOut=>60) +; my $msg=MIME::Lite->new ( From=>"$from_name <$from_email_address>", To =>"$to_email_address", Subject=>"$subject_of_email", Type=>'text', Data=>$body_of_email ); $msg->send;

    There is also Mail::Sender and Net::SMTP for you to consider. An example of Net::SMTP code is:

    use Net::SMTP my $smtp=Net::SMTP->new($mailserver_name_or_ip_address); $smtp->mail($from_address); $smtp->to($to_address); $smtp->data(); $smtp->datasend("To: $to_address\n"); $smtp->datasend("From: $from_address\n"); $smtp->datasend("Subject: $message_subject\n"); $smtp->datasend("\n$body_of_email\n"); $smtp->dataend(); $smtp->quit;

Re: Mail modules on W2K
by strat (Canon) on Feb 08, 2002 at 13:31 UTC
    For sending emails with attachments, under Win32 I often use blat from It is rather comfortable and somewhere (CPAN?) also exists a Perl-Interface (which I've never used yet). The only problem is the following: It doesn't run under Non-Win32-Systems...

    Best regards,
    perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"

Re: Mail modules on W2K
by Zo (Scribe) on Feb 07, 2002 at 17:41 UTC
    Thank you all for your help.
    FYI: I am using ActiveState Perl, and used the PPM for many modules, and I also had gone to CPAN and downloaded more. With the Mail::Mailer, my code was similar, almost exact to what you all had. I tooled around and I'm still banging the keyboard against the wall w/frustration.

    I then tinkered/tried using the Win32::OLE that RhetTbull posted above and it basically worked.
    Thank you all so much for the extra set of eyes and teaching me the ways of Perl.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://143904]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2019-05-25 21:47 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (152 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!