in reply to Re: Sending mail on a Win32 platform
in thread Sending mail on a Win32 platform

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?

Replies are listed 'Best First'.
Re^3: Sending mail on a Win32 platform
by robartes (Priest) on Feb 25, 2003 at 07:49 UTC
    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-

      here is a file that i created with a few examples using Mail::Sendmail and Mail::Sender. Overall Mail::Sender is more useful allowing attachments to be sent.Hope this helps.
      Sean

      use Mail::Sendmail; #originally investigated--does not allow for incor +poration of attachments use Mail::Sender;#better allows single attachments + multiple attachme +nts use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); ###Sending simple message Mail::Sendmail module ####################################################### print $R::imp_email; print "hello"; %mail = ( To => 'bill.bragg@indiq.net', From => $R::imp_email, Message => "This is a very short message" ); $rc=sendmail(%mail);#1 on success, 0 on error if (!($rc)) { print $Mail::Sendmail::error; } print "OK. Log says:\n", $Mail::Sendmail::log; #Simple message--Mail::Sender module eval{ $sender = new Mail::Sender {smtp => 'mail1.eircom.net', from => $R::imp_email}; $sender->MailMsg({to => 'bill.bragg@eircom.net', subject => 'Test of Mail Sender Module', msg => "Test of Mail Sender Module"}); if ($Mail::Sender::Error) { print "<B>$Mail::Sender::Error --Please Report This Error< +/B>\n"; print "Also please contact $R::imp_email by phone and tell him/her that a cancel request has been issued for this line\n"; exit; } }; #Adding attachment to mail--Mail::Sender module eval{ $sender = new Mail::Sender {smtp => 'mail1.eircom.net', from => $R::imp_email}; $sender->MailFile({to => 'sean.mccoubrey@eircom.net', subject => 'Test of Mail Sender Module', msg => "Test of Mail Sender Module", file => 'C:\InetPub\scripts\Paris\filxname.txt'}); if ($Mail::Sender::Error) { print "<B>$Mail::Sender::Error -- Please Report This Error +</B>\n"; print "Also please contact $R::imp_email by phone and tell + him/her that a cancel request has been issued for this line\n"; exit; } }; #A different way to add html attachment, Can specify more than one fil +e by comma separating them $sender = new Mail::Sender{smtp => 'mail1.eircom.net', from => $R::imp +_email}; (ref ($sender->MailFile( {to =>'tom.thumb@isp.net', subject => 'this is a test', msg => "Hi Johnie.\nI'm sending you the pictures you wanted.", file => 'C:\InetPub\scripts\Paris\index.html' })) and print "Mail sent OK." ) or die "$Mail::Sender::Error\n"; if ($Mail::Sender::Error) { print "<B>$Mail::Sender::Error --Please Report This Error</B>\n"; print "Also please contact $R::imp_email by phone and tell him/her + that a cancel request has been issued for this line\n"; exit; }

      update (broquaint): added <code> tags and removed excessive whitespace

      Yes, thank you - that works. Here's the example code from The Perl Journal that was passing a hash to this routine and made me perplexed.