Search code examples
ruby-on-railsruby-on-rails-pluginsactionmailer

Rails ActionMailer with the restful authentication plugin won't deliver mail


I've been working on a rails app that uses the restful authentication plugin. It requires a new user to activate their account through email verification. This has been working up until a few hours ago, when the application suddenly started to fail on email delivery. Instead I am greeted with the following error message:

 undefined method `perform_delivery_SMTP' for #<UserMailer:0x28ec7ac>

I've reverted to an old revision, created new apps with actionmailer, reinstalled rails, reinstalled all plugins and gems but the error persists. Has anyone ever seen this error before? It would seem I need to add the perform_delivery_SMTP method to the UserMailer model, but how and why? Thanks.


Solution

  • Where do you configure your mailer?

    I am guessing that your delivery method is set like this

    ActionMailer::Base.delivery_method 'SMTP'
    

    Use :smtp instead of 'SMTP'

    ActionMailer assumes you will use :smtp, :sendmail or :test

    It uses that in the deliver! method like so

    __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
    

    which means that when delivery_method is set to 'SMTP' it will try to call perform_delivery_SMTP, which doesn't exist as you found out. When you use the symbol :smtp it calls perform_delivery_smtp, which does exist.