Quoted-printable – crossing the 1000 character SMTP barrier

Sent a long email with a text attachment that got messed up? Did you know that SMTP has a 1000 character limit – it’s well documented but then again, who reads the manual?

Here’s a nice post from Shifa that explains the problem and how to solve it.

Noob Snippets

While sending some lengthy text files as email attachments, I discovered that some of my sentences were broken mid-word into new lines. Turns out, SMTP protocol allows only 1000 characters per line. Each line is to be wrapped at 998 characters by a CRLF (rn). Now, most email platforms such as Mandrill and SendGrid follow this rule, but Gmail seems to bypass it somehow. This prompted me to further look into workarounds to keep the attachment formatting as is.

Action Mailer Rails Guides tell you that the Mail gem automatically guesses the attachment content type, encoding and creates the attachment. The default content-type is ‘plain/text’. So I tried playing around with different content-types/ mime-types, for example text/tab-separated-values (Since I had a tab separated format) hoping they would be treated differently from plain text. But that didn’t do the trick.

After reading up some more about the SMTP line limits

View original post 291 more words

Advertisements

About Gautam Rege

Rubyist, Entrepreneur and co-founder of Josh-Software - one of the leading Ruby development shops in India.
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s