in reply to Re^3: Trap the error msg from Mime::Lite
in thread Trap the error msg from Mime::Lite

As per my orig post, I did it deliberately, in order to force the error, so I could test the error handling....
Unfortunately I can't 'grab' the error msg for further processing....
  • Comment on Re^4: Trap the error msg from Mime::Lite

Replies are listed 'Best First'.
Re^5: Trap the error msg from Mime::Lite
by hipowls (Curate) on Jan 22, 2008 at 07:39 UTC

    send spawns out to sendmail. If you have Net::SMTP installed you can use

    eval { $msg->send_by_smtp; }; if ($@) { # handle error }

Re^5: Trap the error msg from Mime::Lite
by Corion (Patriarch) on Jan 22, 2008 at 07:32 UTC

    I'm stupid and didn't read your message, sorry!

    I think the string you see comes from the sendmail program directly. Maybe you can close STDERR in the hope that that will shut up the sendmail error output. Otherwise, you could skip using sendmail and talk SMTP directly, but not every machine is set up for that either:

    $msg->send('smtp','some.host.local');
Re^5: Trap the error msg from Mime::Lite
by chrism01 (Friar) on Jan 23, 2008 at 00:01 UTC
    Hi guys,
    tried both those, but got 'Error: Failed to connect to mail server: Connection refused at ./m.pl line 53' in both cases.
    Seems it doesn't like smtp... weird huh?