ActionMailer NoMethodError 'deliver'

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

ยทยทยท

On Jul 27, 2005, at 7:01 AM, enspired wrote:

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.

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.

Jamis,

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