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'
end
end
And a view in app/views/hello_notifier/hello_world.erb
that looks like this:
Hello
World
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'?
Try to rename your view to hello_world.text.erb
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
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
精彩评论