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

The error message

No recipient addresses found in message header

seems to confirm that you never set $contact_email. Did you just remove your email address from the line initializing it for privacy reasons or is the recipient really empty?

$contact_email = 'chrism01@example.com';

would be an example of initializing the email address. Of course, you would possibly use a local email address instead of an address that is routed through the internet.

Replies are listed 'Best First'.
Re^4: Trap the error msg from Mime::Lite
by chrism01 (Friar) on Jan 22, 2008 at 07:11 UTC
    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....

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

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

      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');
      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?