marynella has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone!

I'm using MIME::Lite so send some emails with some pdfs attached.

I need to redirect the bounced email to a certain address. So I used Errors-To: header field. (I do not want to modify the Return-path header field)

my $msg = MIME::Lite->new( From => $from, Reply-To => $replyto, To => $email, Cc => $temp_email, Bcc => $cemail, Errors-To => $errors, Subject => $subj, Type => $type, Data => $htmlt );

The problem is I don't receive the bounces.
I made a test, with 2 invalid addresses (one with an unexisting domain and one with an unexisting user) and I receive no bounce at all.

When I look at test messages that I send to myself, there is no such "Errors-to:" line.

More if I list the header of the email:

$str = $msg->header_as_string; print "\n<br> Header: \n<br>".$str."<br>\n";
I get: Header: Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1082036677888920" MIME-Version: 1.0 Date: Thu, 15 Apr 2004 05:30:40 -0800 From: LKK Cc: test@test.com Subject: Distribution Code:2 X-Mailer: MIME::Lite 3.01_03 (F2.71; A1.60; B3.00; Q3.00)

Any sugestion?

Thanks

Replies are listed 'Best First'.
Re: MIME::Lite + bouce email address
by tachyon (Chancellor) on Apr 15, 2004 at 12:47 UTC

    It is not supported by MIME-Lite by default because the mail transport standards dictate that error reports should go the the envelope from. Errors-To is not a known or valid email header according to standards, and mail transport systems are under no obligation to do anything at all with them.

    If you want to make MIME-Lite send that header just call it 'Errors-To:' (ie add a :) and MIME-Lite will add the header. It will probably only work some of the time though for the reasons noted above.

    use MIME::Lite; my $msg = MIME::Lite->new( From => 'from', Reply-To => 'replyto', To => 'email', 'Errors-To:' => 'errors', Subject => 'Errors to header', Data => 'Add a :' ); print $msg->as_string; __DATA__ Content-Disposition: inline Content-Length: 7 Content-Transfer-Encoding: binary Content-Type: text/plain MIME-Version: 1.0 X-Mailer: MIME::Lite 3.01 (F2.6; B2.12; Q2.03) Date: Thu, 15 Apr 2004 12:56:05 UT From: from To: email Errors-To: errors Subject: Errors to header Add a :

    cheers

    tachyon

      Thanks,
      your solution works (the 'Errors-To' header is added) but still I don't get any bounces.

      Maybe someone knows other solution (except using 'Errors-To' header) to redirect the bounced emails ...

      Thanks!
        The Errors-To header is for Usenet messages. It does not do anything for email.

        The only way to control where bounce messages go is by changing the envelope sender in SMTP. This will be placed in the Return-Path header by the receiving SMTP server. The envelope sender can be different than From: header but this requires more control of the sending process. Most mechanisms will use the From: header by default.

        How are you sending the mail? The sendmail program has a command-line option (-r) to set the envelope sender. The SMTP modules I know, Net::SMTP and Mail::Sender, have ways to specify the envelope sender.

Re: MIME::Lite + bouce email address
by neilwatson (Priest) on Apr 15, 2004 at 12:53 UTC
    Check the documentation on how to capture MIME::Lite error messages. Then see if perhaps you have missed something. Looking through my version of MIME::Lite I don't even see the ability to add an Errors-To header.

    Neil Watson
    watson-wilson.ca

      Thanks for the advice.

      send method returns false if there is an error (ie 'To' => 'dfhf'). If you write a correct email address ('nothing@anywhere.ff')but non existing you don't get any error.