ActionMailer NoMethodError 'deliver'

E

enspired

I have created a mailer class ReservationMailer < ActionMailer and
defined a couple of methods on it for confirm and remind. When trying
to send an HTML email I use the dynamic method
ReservationMailer.create_confirm(reservation) and then set the content
type to text/html. The code basically looks like this:

email = ReservationMailer.create_confirm(reservation)
email.set_content_type("text/html")
ReservationMailer.deliver(email) #this line raises NoMethodError

I've also tried ReservationMailer::deliver(email) and it raises the
same exception. The message is "undefined method 'deliver'".

I am developing on Windows XP Professional, Rails 0.13.
 
J

Jamis Buck

I have created a mailer class ReservationMailer < ActionMailer and
defined a couple of methods on it for confirm and remind. When trying
to send an HTML email I use the dynamic method
ReservationMailer.create_confirm(reservation) and then set the content
type to text/html. The code basically looks like this:

email = ReservationMailer.create_confirm(reservation)
email.set_content_type("text/html")
ReservationMailer.deliver(email) #this line raises NoMethodError

I've also tried ReservationMailer::deliver(email) and it raises the
same exception. The message is "undefined method 'deliver'".

I am developing on Windows XP Professional, Rails 0.13.

The way to specify the content type of emails is using the
'content_type' accessor within your "create" method:

def confirm(reservation)
content_type "text/html"
...
end

...
ReservationMailer.deliver_confirm(reservation)

Unfortunately, documentation for ActionMailer is still sadly lacking,
and I apologize for that. I'll do something about that soon.

- Jamis
 
E

enspired

My original code is the way it is explained even in the release version
of "Agile Web...with Rails". I'll give this a try and see if it
resolves the problem. I appreciate the response.
 
E

enspired

Jamis,

Your code did the trick and I now have emails functioning in
production. Thanks for the correction.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top