Send Mime Messages With SendGrid

Sending MIME Mail

Some mail clients, such as Outlook and Thunderbird, appear to insert double spacing line breaks at every line. The reason is that those mail clients set the 'content-transfer-encoding' in MIME to 'quoted-printable' which adds Carriage Return Line Feed (CRLF) line breaks to the source content of the email which are characters interpreted by these mail clients. To alleviate this problem, please do the following:

  1. If you can customize the MIME settings for your email, set the 'Content-Transfer-Encoding' to '7bit' instead of 'Quoted-Printable.'
  2. Ensure that your content follows the line length limits.
  3. Line breaks appear as CRLF characters in the source of an email with the character combination of " =0D" in the source of an email. These characters appear only with 'quoted-printable' (Content-Transfer-Encoding set in MIME) emails. Email clients such as Outlook and Thunderbird render these characters which resulting in additional breaks in the content of your emails.

Use the MIME layout in your email below when sending through SendGrid. It is best to reference files using separate links to download since it lowers the percentage of spam threshold for most domains you are sending to.

Sending email with multiple content types (text+html)

email =

email.from = '')

email.subject = "App - Reset Password"

per = =, name:

per.substitutions = "user_name", value:" ")[0].capitalize)

per.substitutions = "reset_link", value: some_func(token, email:

email.personalizations = per

email.contents = 'text/html', value: 'test')

email.contents = 'text/plain', value: "Hi #{}.. Click the following link to reset your password.. #{function_reset(token, email:}... This link will expire in two hours.. If you did not request your password to be reset, please ignore this email and your password will stay as it is.")

email.template_id = "6ede18bb-2eba-4958-8a57-43a58a559a0a"

response = @@sg.client.mail._('send').post(request_body: email.to_json)

puts response.status_code

puts response.body

puts response.headers
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more