Wednesday, August 12, 2009

perl MIME::Lite sendmail Return-Path fix/override

I'm not sure this affects the newest version of MIME::Lite; however, if you find that you are having issues with your messages being rejected or marked as spam, due to an internal host being added to the Return-Path, the following fix might work for you.

Rather than using:
my $ml = MIME::Lite-new(
    From => ...
To => ...
...
);

$ml->send();

Use the following:
$ml->send_by_sendmail(SetSender => 1);

1 comment:

  1. If you control the sendmail, you can add your user account to trusted-users and then just mail using MIME::Lite slightly differently during send:

    $ml->send("sendmail","/usr/lib/sendmail -r $from -t -oi -oem");

    This is particularly useful if you are mailing from CGI, in which case you add the user account under which your webserver runs to trusted-users. Should mail now bounce, it will go to the addres in $from and not to the webserveraccount@internal_host.

    ReplyDelete