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

Hello, Monks,

I have unsuccessfully tried to run the Mail::Mailer and Mail::Sendmail examples under Windows platform. Haven't found how to setup them so they work too. Can anyone point out how to do that? I run my perl CGI scripts on a Windows machine and I want to use our SMTP mail server which is on a Linux machine.

Thank you very much.

Replies are listed 'Best First'.
Re: Sending mail on a Win32 platform
by Marza (Vicar) on Feb 25, 2003 at 07:14 UTC

    Let's see your code. I use it all the time. I would show you an example but I can't get access to our network for some reason! So if nobody else responds, I will post something in the morning.

    UPDATE

    Personally, I tend to like MIME::Lite better. HEre is a sub I used to sendmail messages about ftp downloads, errors, etc. We have a sendmail server on a sun box.

    sub SendMail { my ($recipients, $subject, $msg) = @_; $msg=MIME::Lite->new( To => "$recipients", From => "$fromAddress", Subject => "$subject", Type => 'text/html', Data => "$msg" ); MIME::Lite->send('smtp', "$mailhost"); $msg->send(); }
      The code is (this one's an example from The Perl Journal):
      #!C:\Perl\bin\perl -w use Mail::Mailer qw/smtp/; my $mailer = new Mail::Mailer 'smtp', Server => "elinara.ktu.lt"; $mailer->open(To => ['mindaugas@elinara.ktu.lt'], Cc => ['mindaugas@elinara.ktu.lt'], From => 'mindaugas@elinara.ktu.lt', Subject => 'Some test mail'); print $mailer "Message Body.\n"; $mailer->close;
      The script is executed, but I don't gen an e-mail. What might be wrong here?
        Hi, according to the Mail::Mailer docs, you need to pass a hashref with the headers, you're passing a hash. Try this:
        $mailer->open({ ( To => ['mindaugas@elinara.ktu.lt'], Cc => ['mindaugas@elinara.ktu.lt'], From => 'mindaugas@elinara.ktu.lt', Subject => 'Some test mail' ) } );
        Does that work?

        CU
        Robartes-

Re: Sending mail on a Win32 platform
by signal9 (Pilgrim) on Feb 25, 2003 at 15:24 UTC
    Why not use Net::SMTP?
      I was about to say the same thing, as Net::SMTP is a core module, I usually prefer to use core modules, if it provides the functionality I want.

      But as you said it already, I gained more time to look into the Mail:: stuff, source code and document, and think about those a little bit more.

      Hey, I do like it. The Mail::Mailer and other supporting classes are done in a “real” OO-style. They had all the entities abstracted, for example, they have this Mail::Address class to wrap RFC822 mail addresses. That’s what the OO-style codes are supposed to look like, at least in theory. The design is neat.

      I am not saying Net::SMTP is bad, on the contrary, for myself I would still use Net::SMTP, as it is slim.