eval { $mailer->open(\%headers); print $mailer $msg; $mailer->close;};if ($@){# error occured - at the very least log it before doing a callback}else {# optional - log and do callback, or skip the else and just do a callback}