2010-09-25 42 views
7

我已經設置了以下。確認電子郵件從devise on rails3使用Gmail不到達

---------------------- 
config/environments/development.rb 
---------------------- 
29 ActionMailer::Base.delivery_method = :smtp 
30 ActionMailer::Base.perform_deliveries = true 
31 ActionMailer::Base.raise_delivery_errors = true 
32 
33 ActionMailer::Base.smtp_settings = { 
34  :enable_starttls_auto => true, #this is the important stuff! 
35  :address  => 'smtp.gmail.com', 
36  :port   => 587, 
37  :domain   => 'foo.com', 
38  :authentication => :plain, 
39  :user_name  => '[email protected]', 
40  :password  => '---' 
41 } 

然而,當色器件發送確認電子郵件webbrick打印出 日誌,沒有錯誤的電子郵件,但郵件沒有最終在我的收件箱或垃圾郵件收件箱 。

任何想法?

編輯:

I now get 

    Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. x13sm2646038bki.0 

):

我發現

---------------------- 
config/environments/development.rb 
---------------------- 
17 # Don't care if the mailer can't send 
18 config.action_mailer.raise_delivery_errors = false 

已經建立了較高的配置文件。然而,發佈STARTTLS命令的這是什麼?

SOLUTION:

---------------------- 
config/environments/development.rb 
---------------------- 
26 require 'tlsmail' #key but not always described 
27 Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) 
28 
29 ActionMailer::Base.delivery_method = :smtp 
30 ActionMailer::Base.perform_deliveries = true 
31 ActionMailer::Base.raise_delivery_errors = true 
32 
33 ActionMailer::Base.smtp_settings = { 
34  :enable_starttls_auto => true, #this is the important stuff! 
35  :address  => 'smtp.gmail.com', 
36  :port   => 587, 
37  :domain   => 'xtargets.com', 
38  :authentication => :plain, 
39  :user_name  => '-------', 
40  :password  => '-------' 
41 } 
42 

布拉德

回答

5

我有同樣的問題;在我的情況下是由於一個錯誤(Net :: SMTP不說如何說TLS,這是gmail所要求的),我解釋了它,如解釋here

+0

非常感謝。這工作完美:) – bradgonesurfing 2010-09-25 17:25:09

+0

我必須編輯從設計sign_up電子郵件的哪個文件? – shibly 2011-10-09 01:44:35

0

而不是全局關閉SSL證書驗證,你可以傳遞一個額外的參數smtp_settings:

config.action_mailer.smtp_settings = { 
    :address    => 'smtp.example.com', 
    :port     => '25', 
    :domain    => 'example.com', 
    :user_name   => '[email protected]', 
    :password    => 'secret', 
    :authentication  => 'plain', 
    :enable_starttls_auto => true, 
    :openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, 
} 

您可能還需要require 'openssl'得到那個常數。

如果您在:via_options散列中包含:openssl_verify_mode,此解決方案也適用於Pony

+0

你在最後似乎有一個額外的尾隨逗號。 – Noz 2013-05-21 21:51:21