Ethan
Ethan

Reputation: 60179

How do you send plaintext instead of HTML email from Rails?

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.

Upvotes: 6

Views: 7489

Answers (2)

Simone Carletti
Simone Carletti

Reputation: 176562

Be sure your template ends with .text.erb extension and not .html.erb. See ActionMailer documentation.

Upvotes: 15

Jim Puls
Jim Puls

Reputation: 81142

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.

Upvotes: 1

Related Questions