2012-07-29 71 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

相关问题