我试图通过谷歌应用程序使用smtp配置actionmailer。

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 user@my.domain.com (10ms)
Completed 500 Internal Server Error in 29ms

535-5.7.1 Username and Password not accepted
.

服务器运行Ruby 1.9.3p194。为什么Google Apps不接受用户名/密码?

有帮助吗?

解决方案

现在工作,我认为问题在于用户名。它需要用户名中的域。即问题是

user_name: 'username'
.

而正确的方式(至少用于Google Apps)是

user_name : 'username@mydomain.com'
.

其他提示

这适用于我:

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

尝试将域设置为gmail.com

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top