Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.0, ActionMailer delivery not working, no error message displayed

I'd like to play around with sending mail from Rails in a development environment. My message is getting rendered (I can see it in the terminal I'm running rails console in).

In config/development.rb I have (yes, the port is really 26):

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
  :address  => "mail.mydomain.com",
  :port  => 26,
  :user_name  => "[email protected]",
  :password  => "removed",
  :authentication  => :login
}

I have in mailers/user_mailer:

class UserMailer < ActionMailer::Base
  default from: "[email protected]"
  def send_an_email
    mail(:to => "[email protected]", :subject => "Test from Rails")
  end
end

I have a view that's getting rendered properly in views/user_mailer/send_an_email.text.erb. I'm calling UserMailer.send_an_email.deliver upon a page request.

Rails doesn't complain about my configuration. I see the message in the rails server console output. However, I never get an e-mail, and I don't see any error messages in the console output (as you can see above, raise_delivery_errors = true!.

like image 242
Steve Avatar asked Dec 14 '25 16:12

Steve


1 Answers

Steve, by chance have you made sure you're calling the deliver method?

mail(:to => "[email protected]", :subject => "Test from Rails").deliver

I forgot to do that, and was quite confused by the lack of errors. :)

like image 171
bvaughn Avatar answered Dec 16 '25 20:12

bvaughn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!