I'd like to send plain text emails from a Rails app. In my mail sending config I have:
ActionMailer::Base.default_content_type = 'text/plain'
Nonetheless, when I send a test email from the Rails console, I get:
>> GeneralAppMailer.deliver_test
# ...
Content-Type: text/html; charset=utf-8
And looking at it in Gmail, it does seem to be handled as HTML.
I don't know how are you sending email from HTML, but all you have to do is to set header to Content-Type: text/plain;" instead of Content-Type: text/html;" . Then your email content will be sent as plain text without any parsing.
Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.
A plain text email contains only text—no images, stylized fonts, or hyperlinks. Multi-part MIME (Multipurpose Internet Mail Extensions) bundles together a plain text version and an HTML version of the deployed email.
Be sure your template ends with .text.erb
extension and not .html.erb
.
See ActionMailer documentation.
Without seeing the test
method in your GeneralAppMailer
class, it's impossible to say, but it's probably because you're rendering an HTML-based view template to send the message. But maybe you should post your code.
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