rails email error – 530-5.5.1需要validation。
尝试从Ruby on Rails发送电子邮件,但得到这个:
SocketError in UsersController#create getaddrinfo: nodename nor servname provided, or not known
我的environment / development.rb文件有:
config.action_mailer.smtp_settings = { address: "smtp.gmail.com", port: 587, domain: "my_company.org", authentication: "plain", enable_starttls_auto: true, user_name: "my_username@my_company.org", password: "my_pass" }
和
config.action_mailer.delivery_method = :smtp
和
config.action_mailer.default_url_options = { :host => 'localhost:5000' } # 5000 rather than 3000 as I am using foreman.
我使用我的Gmail做了同样的事情,以下是我的配置,尝试查看它是否有效
config.action_mailer.default_url_options = { :host => 'localhost:3000' } ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :authentication => :plain, :user_name => "@gmail.com", :password => " ", :openssl_verify_mode => 'none' }
请注意
:openssl_verify_mode => 'none'
部分跳过SSL错误。
但抱歉,我不知道错误是什么,可能您尝试将Gmail SMTP服务器与其他域名一起使用。
如果其他人面临同样的问题,我只想补充一点,我试图在我的Rails API中使用gmail实现邮件系统时遇到了同样的问题,并添加:openssl_verify_mode => 'none'
并没有为我解决问题。
相反,安装figaro gem然后在application.yml
添加我的环境变量,如下所示:
gmail_username: "myemail@gmail.com" gmail_password: "mypassword"
为我做了诀窍。
(并且别忘了更改SMTP设置:)
user_name: ENV['gmail_username'], password: ENV['gmail_password'],