You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SMTP standard uses \r\n.\r\n (a period on a line by itself) to indicate "end of message". While using Mail::Part (via ActionMailer), I discovered that Mail::Part#encode does not escape lines that consist of a single period on a line by itself, which causes the receiving SMTP server to cut the email short.
Here's example code that reproduces the issue:
html_body="<p>This is HTML and it can have linebreaks anywhere, which this will have.This is the next sentence, but it's too late. Everything on this line and after will be rejected by the server.</h1>"defcreate_mail(html_body)mail=Mail.newdoto'nicolas@test.lindsaar.net.au'from'Mikel Lindsaar <mikel@test.lindsaar.net.au>'subject'First multipart email sent with Mail'content_type'text/html; charset=UTF-8'bodyhtml_bodyendmail.transport_encoding='quoted-printable'mailendputscreate_mail(html_body).encoded
The resulting output includes these lines:
Content-Transfer-Encoding: quoted-printable
<p>This is HTML and it can have linebreaks anywhere, which this will have=
.
This is the next sentence, but it's too late. Everything on this line and=
after will be rejected by the server.</h1>=
As mentioned in said output, the second half of the content of the email cannot be delivered, because the server rejects all lines after the first line containing nothing but a single period.
In order to implement quoted-printable encoding in a way that can be transmitted over SMTP, the Mail::Part#encode method needs to escape lines containing nothing but a period by adding another period to the beginning of the line. Two periods are interpreted as a single period that does not end the email according to rfc5321 section 4.5.2.
The text was updated successfully, but these errors were encountered:
The SMTP standard uses
\r\n.\r\n
(a period on a line by itself) to indicate "end of message". While using Mail::Part (via ActionMailer), I discovered that Mail::Part#encode does not escape lines that consist of a single period on a line by itself, which causes the receiving SMTP server to cut the email short.Here's example code that reproduces the issue:
The resulting output includes these lines:
As mentioned in said output, the second half of the content of the email cannot be delivered, because the server rejects all lines after the first line containing nothing but a single period.
In order to implement quoted-printable encoding in a way that can be transmitted over SMTP, the
Mail::Part#encode
method needs to escape lines containing nothing but a period by adding another period to the beginning of the line. Two periods are interpreted as a single period that does not end the email according to rfc5321 section 4.5.2.The text was updated successfully, but these errors were encountered: