So I have a script that I'm trying to get VERP running correctly on. It's using MIME::Lite and postfix as the mail server. Here is the code:
use strict;
use MIME::Lite;
use LWP::Simple;
use Mail::Verp;
my $email = '[email protected]';
Mail::Verp->separator('+');
my $verp_email = Mail::Verp->encode('[email protected]', $email);
my $content = '<html><body>Hi!</body></html>';
my $msg = MIME::Lite->new(
Subject => 'Hi',
From => '[email protected]',
To => $email,
'Return-Path' => $verp_email,
Type => 'text/html',
Data => $content
);
$msg->send('smtp', 'XXX.XXX.XXX.XXX');
When the message is bounced postfix isn't routing it to the [email protected] email inbox. How do I route the message so that the sender of the bounce is the $verp_email value?
I'm trying to create a log of all bounced emails with the email addresses included so that it can then be sent to a file or a database.
If anyone can point me in the right direction with this I would be extremely appreciative. Thanks.
The question is a bit old, but hopefully my answer will contribute to someone who find this while googling. I had the same problem, and the root cause is that you must use "MAIL FROM: " during the smtp exchange with the target server. Setting the return-path in the MIME::Header gets overwriten by the smtp server itself precisely based on the MAIL FROM smtp command. So you can have a Mail envelope containing From: [email protected] but make sure the smtp MAIL FROM uses $verp_email For example, this is what I have done: