SMTP legacy

Some things still wonder me, after 10+ years of web-development. Todays wonder is here:

RFC2821 (SMTP) tells: The maximum total length of a text line including the <CRLF> is 1000 characters. In real world, most MTAs default to 990 characters per-line, which means, that if you will try to dump longer line on them, they would split it by putting “!\n” after 990-th byte. This is mostly harmless for plain-text, but can easily break html.

Actually, there is even a PHP-bug reported, regarding this, but PHP obviously can’t do anything to help the situation

The solution is really simple: if there is a chance, that lines of your emails would be longer than 990 bytes encode body using base-64. The easiest way to do it for emails without attachments, in php is to use mb_send_mail() function instead of mail(), as it will apply encoding automatically.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • DZone
  • FriendFeed
  • Reddit
  • Tumblr
  • Twitter

View CommentsSMTP legacy

  • Another solution is to encode your mail bodies using quoted-printable, either with a pure PHP solution or using the imap_8bit() function from the IMAP lib.

    Agreed, it does show how arcane the whole internet mail thing really is :)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

blog comments powered by Disqus