markov2 / perl5-Mail-Message

Processing MIME messages
http://perl.overmeer.net/CPAN
1 stars 1 forks source link

Sending hostname being incorrectly added to email address on send #3

Closed abeverley closed 2 years ago

abeverley commented 2 years ago

I am not sure whether this problem is within Mail::Message itself or the MTA (Postfix).

Under certain circumstances (a long phrase including a semicolon) the hostname gets appended to part of the phrase. The following example demonstrates it:

my $e = '"John Smith ;Connor - this is some additional text to make long phrase" <andyjohns@example.com>';

my $msg = Mail::Message->build(
    To      => 'something@example.com',
    From    => $e,
    Subject => "My subject line",
    data    => "Some body text",
);

my ($from_orig) = $msg->from;
my $from = Mail::Message::Field::Address->parse($from_orig);

my $f = Mail::Message::Field::Address->new(
    address => $from->address,
    phrase  => $from->phrase,
);
$msg->head->set(From => $f);

$msg->send(via => 'postfix');

When this arrives at the recipient, the from email address has changed to:

"John Smith @www.example.com;Connor - this is some additional text to make long phrase" <andyjohns@example.com>

It seems that something is considering the semicolon an address separator and is then appending the local hostname to the phrase before it.

markov2 commented 2 years ago

The current implementation used the RFC2045 rules for Quoted-Printable Transfer Encoding. This was a mistake: it should have been the RFC2047 section 4.2 & 5 definition, which has a smaller set of acceptable characters. So: the ';' was not allowed here.

Issue #2 was slightly different: that one was about the need for being more flexible in receiving encodings.

abeverley commented 2 years ago

Great, thanks Mark.

markov2 commented 2 years ago

Please feed me with more bug reports ;-)

abeverley commented 2 years ago

One to follow shortly ;-)