I am wanting to write to a file any emails that are unable to be sent, rather than the application 'dying'. This will ensure that a bogus email address doesn't stop the rest of the emails being sent. For the $msg->sent part of the subroutine I have tried using or warn and printing to a file with no success. Can someone please give me a idea on how to achieve this goal. Thankyou very much.sub sendEmail { my($email, $c_first) = @_; $msg = MIME::Lite->new( To =>$email, From =>'marketing@taieriprint.co.nz', Subject =>$subject, Type =>'multipart/related' ); $msg->attach(Type => 'text/html', Data => qq{<html> <HEAD> <TITLE>Taieri Print Ltd</TITLE> </HEAD> <body bgcolor="#DBDBDB"> <table align="center" width="645" border="0" bgcolor="whit +e"> <tr><td align="center"><img src="cid:tplogo.gif"></td> </tr><tr height="3" CELLPADDING=20><td align="right"><font siz +e="2" face="Microsoft Sans Serif">$Month $Year</font></td></tr></tabl +e> <table CELLPADDING=20 align="center" width="645" bgcolor="whit +e"> <tr><td align="left"><font face="Microsoft Sans Serif" size="2 +">Dear $c_first,</font><br> <font face="Microsoft Sans Serif" size="2">$message</td></tr>< +/font> <tr><td align="center"><font size="1" face="Microsoft Sans Ser +if"><br>We hope you have enjoyed recieving this message. However, if you'd rather not recieve future newsletters from u +s, then please <a href="mailto:mailbird@taieriprint.co.nz?subject=Unsubsc +ribe"> click here</a> to unsubscribe. </td></tr></table> </body> </html> } ); $msg->attach(Type => 'image/gif', Id => 'tplogo.gif', Path => 'C:/mailbird/tplogo_new.gif', ); if ($query->param('attach')) { $msg->attach(Type => 'application/pdf', Path => $attachment, Filename => $filename); } $msg->send('smtp', 'smtp.taieriprint.co.nz') or warn print "Una +ble to send email: $_"; return; }
In reply to Email error checking by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |