- local $SIG{__DIE__}; # don't want Mason __DIE__ handler active
- local $@; # just in case
- eval { sendmail($message, { transport => $transport,
- from => $from,
- to => \@env_to }) };
+ unless ( length($error) ) {
+
+ local $SIG{__DIE__}; # don't want Mason __DIE__ handler active
+ local $@; # just in case
+ eval { sendmail($message, { transport => $transport,
+ from => $from,
+ to => \@env_to }) };
+
+ if (ref($@) and $@->isa('Email::Sender::Failure')) {
+ $error = $@->code.' ' if $@->code;
+ $error .= $@->message;
+ } else {
+ $error = $@;
+ }