Subject: | Mail::Sender incorrectly extracts From address when using SMTP auth |
Date: | Wed, 22 Jul 2015 15:31:54 +0800 |
To: | bug-Mail-Sender [...] rt.cpan.org |
From: | se456 [...] rohan.id.au |
In some circumstances Mail::Sender doesn't correctly deal with
"from" addresses like the following:
Realname <local@dompart.com>
I'm also explicitly defining auth=>"PLAIN",tls_required=>1,authid=>"xxx",authpwd=>"yyy"
It ends up sending this during the SMTP transaction:
MAIL FROM:<local@dompart.com >
Notice the extra space before the end of the line, which is rejected by strict mail servers.
I suspect it's something to do with line 1366 in Sender.pm, but I don't understand what it's trying to do:
$_ = send_cmd $s, "MAIL FROM:<$self->{'fromaddr'}>$self->{esmtp}{_MAIL_FROM}";
And also line 227:
$self->{esmtp}{_MAIL_FROM} .= " $_=$self->{esmtp}{$_}"
if $self->{esmtp}{$_} ne '';
However it handles "to" addresses like "Realname <local@dompart.com>" fine.
My workaround is to pre-process the 'from' address in the caller, like this:
use Mail::Address;
my @a = Mail::Address->parse($from);
$smtp_from = return $a[0]->address;
I supply $smtp_from as the "from" value, and $from as the "fake_from" value.
Thanks,
Rohan Carly.
Realname <local@dompart.com>
I'm also explicitly defining auth=>"PLAIN",tls_required=>1,authid=>"xxx",authpwd=>"yyy"
It ends up sending this during the SMTP transaction:
MAIL FROM:<local@dompart.com >
Notice the extra space before the end of the line, which is rejected by strict mail servers.
I suspect it's something to do with line 1366 in Sender.pm, but I don't understand what it's trying to do:
$_ = send_cmd $s, "MAIL FROM:<$self->{'fromaddr'}>$self->{esmtp}{_MAIL_FROM}";
And also line 227:
$self->{esmtp}{_MAIL_FROM} .= " $_=$self->{esmtp}{$_}"
if $self->{esmtp}{$_} ne '';
However it handles "to" addresses like "Realname <local@dompart.com>" fine.
My workaround is to pre-process the 'from' address in the caller, like this:
use Mail::Address;
my @a = Mail::Address->parse($from);
$smtp_from = return $a[0]->address;
I supply $smtp_from as the "from" value, and $from as the "fake_from" value.
Thanks,
Rohan Carly.