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!.
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. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With