in reply to Re^3: Sending mail on a Win32 platform
in thread Sending mail on a Win32 platform
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
|
|---|