This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Deli Zhang
Recipients Deli Zhang
Date 2015-11-05.06:51:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446706315.09.0.659513655808.issue25553@psf.upfronthosting.co.za>
In-reply-to
Content
It's well known that in quoted-printable encoding the "CRLF" can be encoded to "=CRLF".
For example, in attachment file test.eml, the last line is "test message.=CRLF"
But after the mail is sent via SMTP and received by mail server (e.g. postfix), the last line will become "test message.=", 
then after decoding, you will see the unnecessary char "=" shown following "test message.".

The problem is caused by below code:
------------------------------------------------
class SMTP:
    ...
    def data(self, msg):
        ...
            q = quotedata(msg)
            if q[-2:] != CRLF:
                q = q + CRLF
            q = q + "." + CRLF
            self.send(q)
        ...
------------------------------------------------
Before it sends the message q, it will try to append the end-of-data sequence "<CRLF>.<CRLF>". 
As the implement, it checks whether there is "<CRLF>" in the message end, if yes then just need to append ".<CRLF>".
It looks rigorous and efficient, but it does not consider how mail server handle it.
As we know mail server will remove end-of-data sequence directly, and the left message is treat as mail data.

Thus the corresponding action should be taken on SMTP client side,
it's to say no need to check and just append end-of-data sequence here:
------------------------------------------------
class SMTP:
    ...
    def data(self, msg):
        ...
            q = quotedata(msg)
            q = q + CRLF + "." + CRLF
            self.send(q)
        ...
------------------------------------------------
History
Date User Action Args
2015-11-05 06:51:55Deli Zhangsetrecipients: + Deli Zhang
2015-11-05 06:51:55Deli Zhangsetmessageid: <1446706315.09.0.659513655808.issue25553@psf.upfronthosting.co.za>
2015-11-05 06:51:54Deli Zhanglinkissue25553 messages
2015-11-05 06:51:54Deli Zhangcreate