Take the 2-minute tour ×

I'm have a Rails 2.3.8 app, with a notifier in app/models/hello_notifier.rb that looks like this:

class HelloNotifier < ActionMailer::Base
    def hello_world
        @recipients = 'to@email.address'
        @from = 'from@email@address'
        @subject = 'Hello world'

And a view in app/views/hello_notifier/hello_world.erb that looks like this:


Not when I run HelloNotifier.deliver_hello_world, it delivers the email, but it delivers it as a multipart email with plain and html variations.

I've tried adding @content_type = 'text/plain' to my notifier model as well as content_type 'text/plain'. I've also tried adding ActionMailer::Base.default_content_type = 'text/plain' to my actionmailer initializer. I've also tried renaming my view to hello_world.text.plain.erb. Nothing I try seems to help. It's always sending my email as a multipart html/text email.

Any ideas on how to force it to send as 'text/plain'?

share|improve this question
did hello_world.text.erb not work? Or something like: mail(:to => user.email) do |format| format.text end –  Kyle Patterson Oct 5 '11 at 0:03

3 Answers 3

Try to rename your view to hello_world.text.erb

share|improve this answer
That's doesn't work at all. Then I get ActionView::MissingTemplate: Missing template hello_notifier/hello_world.erb in view path app/views. Just hello_world.erb and the full hello_world.text.plain.erb are both automatically found, but in both cases it renders as multipart with html. –  Ben Lee Oct 5 '11 at 3:30
I think that's the Rails 3 way. This is Rails 2.3. –  Ben Lee Oct 5 '11 at 3:33

Rails 2.3.8 searches template with .erb extension with default content type text/plain.
Try to rename your file name to hello_world.erb

share|improve this answer
As stated in my post, I already tried that. That's the first thing I tried, in fact. –  Ben Lee Oct 5 '11 at 15:08
you never mentioned about .erb thats why i gave this solution.will update you if i got a solution. –  soundar Oct 7 '11 at 12:36
I guess I wasn't clear, sorry. I wrote, "And a view in 'app/views/hello_notifier/hello_world.erb' that looks like this:" but didn't put it in a code block, so it would easy to pass over it. Updated, thanks. –  Ben Lee Oct 7 '11 at 15:39

In Rails 2, you implicitly specify the content type of your email template by giving it one of the following file extensions:

  • .text.plain.erb for plain text emails
  • .text.html.erb for HTML emails

For example, "your_email_template.text.plain.erb" for plain text and "your_email_template.text.html.erb" for HTML.

See also: http://guides.rubyonrails.org/v2.3.8/action_mailer_basics.html

share|improve this answer
Thanks, but as I mentioned in my post, I already tried naming the file hello_world.text.plain.erb and it still sent it as multipart html + text. –  Ben Lee Mar 4 '13 at 1:24

Your Answer


