2010-11-25 51 views
5

我試圖通過使用Action Mailer和Googlemail-SMTP服務器的rails發送郵件,但它不起作用。我究竟做錯了什麼?Rails Action Mailer不發送郵件

下面是我用(我也嘗試了當地的中繼服務器,而無需認證也沒有工作)的配置:

# Action Mailer config 
config.action_mailer.smtp_settings = { 
# Gmail Account 
:tls => true, 
:address => "smtp.googlemail.com", 
:port => "587", 
:domain => "localhost", 
:authentication => :plain, 
:user_name => "[email protected]", 
:password => "dsgdes" 

config.action_mailer.delivery_method = :smtp 
config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = false 
config.action_mailer.default_url_options = { :host => "localhost:80" } 
config.action_mailer.default_charset = "utf-8" 

回答

3

我猜,你的域參數是錯誤的。 我在我的config/initializers目錄寫了一個初始化,它看起來像這樣:

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.perform_deliveries = true 

ActionMailer::Base.smtp_settings = { 
    :address    => "smtp.gmail.com", 
    :port     => "587", 
    :domain    => 'gmail.com', 
    :user_name   => '[email protected]', 
    :password    => 'dsgdes', 
    :authentication  => 'plain', 
    :enable_starttls_auto => true } 
0

這是我用成功地

config.action_mailer.smtp_settings = { 
    :tls => true , 
    :enable_starttls_auto => true , 
    :authentication => :login , 
    :address => "smtp.gmail.com" , 
    :port => 587 , 
    :domain => "smtp.gmail.com" , 
    :user_name => "[email protected].com" , 
    :password => "yourpassword" 
相關問題