2012-07-29 21 views
7

我試圖配置actionmailer通過谷歌應用程序與smtp發送。動作郵件程序SMTP谷歌應用程序

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
:address    => "smtp.gmail.com", 
:port     => 587, 
:domain    => "mydomain.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 

但是每當gitlab嘗試發送電子郵件:

Sent mail to [email protected] (10ms) 
Completed 500 Internal Server Error in 29ms 

535-5.7.1 Username and Password not accepted 

服務器運行紅寶石1.9.3p194。爲什麼Google應用不接受用戶名/密碼?

+1

嘗試登錄到您的Gmail帳戶,您可能需要授予您的應用程序的權限 – 2012-07-29 05:13:05

+0

@KyleC我已經嘗試過。我的應用程序是動作郵件程序。我需要授予SMTP權限嗎? – Jubei 2012-07-29 05:21:15

+2

否....這些錯誤是發生在開發(本地計算機)還是生產中? – 2012-07-29 05:24:51

回答

10

它現在有效,我認爲問題是用戶名。它需要用戶名中的域名。即問題是

user_name: 'username' 

而正確的方式(至少對於谷歌應用程序)是

user_name : '[email protected]' 
5

這個工作對我來說:

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
:address    => "smtp.gmail.com", 
:port     => 587, 
:domain    => "gmail.com", 
:user_name   => "[email protected]", 
:password    => "password", 
:authentication  => 'plain', 
:enable_starttls_auto => true } 

嘗試域設置爲gmail.com

+0

謝謝,對我來說gmail.com也適用,但不適用於谷歌應用領域。 – Jubei 2012-07-29 11:28:04

相關問題