Action mailer SMTP google apps

ぃ、小莉子 提交于 2020-01-11 05:08:06

问题


I tried to configure actionmailer to send via google apps with 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

However whenever gitlab tries to send an e-mail:

Sent mail to user@my.domain.com (10ms)
Completed 500 Internal Server Error in 29ms

535-5.7.1 Username and Password not accepted

Server runs ruby 1.9.3p194. Why doesn't google apps accept the username/password?


回答1:


It works now, I think the problem was with the username. it needs the domain in the username. i.e. the problem was

user_name: 'username'

Whereas the correct way (at least for google apps) is

user_name : 'username@mydomain.com'



回答2:


this works for me:

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  }

Try setting the domain to gmail.com



来源:https://stackoverflow.com/questions/11706277/action-mailer-smtp-google-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!