http://qs1969.pair.com?node_id=11122537

skazat has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

My time in the forest alone writing poetry about nature has been long, but a curious question has crossed my path, and I find myself again in this bustling city.

A user of mine is sending emails that are received with broken URLs. Dots are removed. I suspect a broken sendmail implementation, that's not doing its job dot stuffing, when it finds a dot as the first character of a line, for example:

#!/usr/bin/perl use MIME::Entity; my $str = 'filler text to get the first char of line 2 to be a dot____ +__ http://google.com'; print MIME::Entity->build( Data => $str, Type => 'text/plain', Encoding => 'quoted-printable', )->as_string;
Returns,
Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) filler text to get the first char of line 2 to be a dot______ http://g +oogle= .com=

To me, this seems correct.

One option for me as the app owner is to do this dot stuffing myself, which I am very much against, as I feel it's a hack to a broken system upstream. And I'll probably do it wrong - or at least do it badly. I'll have users now with broken links - but only because there's now too many dots!

Another option is to encode this myself so, "." turns into, "=2E". But, I don't see any way to do this through the tool chain. Looking at the docs for MIME::QuotedPrint, there is no option to encode dots, nor are there any similar options in MIME::Entity, nor is the issue brought up in Net::SMTP. This makes me think that all the authors of all these modules in the tool chain understand this problem better than I, and there was a concerted effort to not do this, "newline starts with a dot encoding".

The only thing similar to this that I have found is that lines that only have a single dot are encoded, stopping the SMTP server from truncating a message, like so:

perl -MMIME::Entity -e 'print MIME::Entity->build(Encoding => "quoted- +printable", Data => "some text\n.\nmore text")->as_string;'

prints,

Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) some text =2E more text=

So, am I missing something obvious? are there solutions that anyone else has come to, to appease broken SMTP clients without needing to post filtering output from MIME::Entity?

-skazat