How to check Rails mail setting
I am trying to debug how rails sends email. Currently it doesn't work for me :)
But where in the configurations do I change the SMTP I am trying to send from? And how to I set it up so that on dev/stage/live it uses appropriate SMTP configurations of the server it is mailing from?
Thanks, Alex
ps - I had originally set it up using this tuto开发者_如何学运维rial: http://guides.rubyonrails.org/action_mailer_basics.html
Examples are assuming that you use the mail server MAIL.YOUR-DOMAIN.COM
Action Mailer now uses the Mail gem -- you probably need something like this in your ./config/environments/env.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "MAIL.YOUR-DOMAIN.COM",
:port => 587,
:domain => 'YOUR-DOMAIN.COM',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
see also: http://edgeguides.rubyonrails.org/action_mailer_basics.html
another way to do this is to put the follwoing into ./config/initializers/setup_mail.rb :
ActionMailer::Base.smtp_settings = {
:address => "MAIL.YOUR-DOMAIN.COM",
:port => 587,
:domain => "YOUR-DOMAIN.COM",
:user_name => "<username>"
:password => "<password>"
:authentication => "plain",
:enable_starttls_auto => true
}
e.g. the code above works if you want to use Gmail's SMTP server to send email via your Gmail account.. Other SMTP servers may need other values for :authentication and :enable_starttls_auto depending on the SMTP server setup
精彩评论