ActionMailer sending incorrect mimetype
I'm using ActionMailer without rails to send multipart emails, but the
html component is being sent with the mimetype "text/plain".
I have templates/mailer/welcome.html.erb and
templates/mailer/welcome.text.erb, and if I run the following code it
raises the error (ie. it has no text/html part)
What am I doing wrong?
require 'action_mailer'
ActionMailer::Base.view_paths = "templates"
class Mailer < ActionMailer::Base
default :from => "me@example.com"
def welcome(variables = {})
@variables = variables
mail(
:to => variables['to'],
:subject => variables['subject'] || "Welcome!"
)
end
end
email = Mailer.welcome({'to' => 'you@example.com'})
raise RuntimeError, "There is no HTML part!" unless email.to_s =~
/text\/html/
No comments:
Post a Comment