My ActionMailer adds a carrige return to the end of every line:
<!DOCTYPE html>=0D
<html>=0D
<head>=0D
...
this is stuff=0D
=0D
This intro has some content in it.=0D
=0D
blah.=0D
=0D
My mail is rendered perfectly fine in the preview host/rails/mailers/user_mailer/periodic_digest.html (and also in mailcatcher), but when I send the mail through Mailgun I end up getting double line spacing between my text.
In app/mailers/user_mailer.rb:periodic_digest
m = mail(from: 'blah', to: 'me')
puts m.html_part.body.decoded
I do get correctly formatted html.
How can I send out my html without the carriage return character =0D being appended to every line?
This isn't an error on Rails' part. Mailgun just handles it in an undesirable manner.
Carriage returns are used to forcibly wrap lines in quoted printable encoded text. If you're sending multipart or plaintext email, RFC 5322 (and 2822 and 822 before it) specify that you must wrap lines at no more than 998 characters. For practical purposes, most email clients wrap closer to 70 characters.
In order to insert a visible newline, you need to use a carriage return followed by a linefeed, which you're probably accustomed to seeing represented as \r\n. This is in contrast to the typical unix-style line endings (just a linefeed) you would have in your code or text files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With