问题
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 = 'someuser@somesite.com';
Mail::Verp->separator('+');
my $verp_email = Mail::Verp->encode('root@somesite.net', $email);
my $content = '<html><body>Hi!</body></html>';
my $msg = MIME::Lite->new(
Subject => 'Hi',
From => 'root@somesite.net',
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 root@somesite.net 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.
回答1:
Return-Path is not the correct place for the VERP address, and will be ignored and/or overridden. You need to put it as the actual, honest to $dmr
, real SMTP envelope sender (MAIL FROM:<>
) address.
回答2:
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: root@somesite.net but make sure the smtp MAIL FROM uses $verp_email For example, this is what I have done:
my $msg = MIME::Entity->build(
'Return-Path' => 'bounce+user=user-domain.com@my-server.com',
'From' => 'admin@my-server.com',
'To' => 'user@user-domain.com',
'Subject' => $subject,
'Errors-To' => 'bounce+user=user-domain.com@my-server.com'
);
## Then some more handling with MIME::Entity
## and finally send it over smtp
my @rcpt = $msg->smtpsend(
## Make it verbose for debugging
'Debug' => DEBUG,
'Hello' => 'mx1.my-server.com',
'Host' => 'mx.user-domain.com,
'MailFrom' => 'bounce+user=user-domain.com@my-server.com',
'To' => 'user@user-domain.com',
'Port' => 25,
);
来源:https://stackoverflow.com/questions/11440475/verp-and-perl-postfix-not-working