rails email error - 530-5.5.1 Authentication Required.

时光总嘲笑我的痴心妄想 提交于 2019-11-30 09:23:47

问题


trying to send email form Ruby on Rails but getting this:

SocketError in UsersController#create
getaddrinfo: nodename nor servname provided, or not known

My environments/development.rb file has:

  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"
  }

and

  config.action_mailer.delivery_method = :smtp

and

  config.action_mailer.default_url_options = { :host => 'localhost:5000' } 
  # 5000 rather than 3000 as I am using foreman.

回答1:


I did the same using my Gmail, following are my configurations, try and see it if works

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  ActionMailer::Base.smtp_settings = {
                    :address        => "smtp.gmail.com",
                    :port           => 587,
                    :authentication => :plain,
                    :user_name      => "<my gmail>@gmail.com",
                    :password       => "<my gmail password>",
                    :openssl_verify_mode  => 'none'
  } 

and please note the

:openssl_verify_mode  => 'none'

section to skip the SSL errors.

But sorry, I have no idea what the error is, probably you try to use the Gmail SMTP server with another domain name.




回答2:


In case others face the same issue, I just wanted to add that I had the exact same problem trying to implement a mailing system with gmail in my Rails API, and adding :openssl_verify_mode => 'none' did not solve the problem for me.

Instead, installing the figaro gem and then adding my environment variable in application.yml like so:

gmail_username: "myemail@gmail.com"
gmail_password: "mypassword"

did the trick for me.

(and dont forget to change you SMTP settings: )

user_name:             ENV['gmail_username'],
password:              ENV['gmail_password'],


来源:https://stackoverflow.com/questions/11724906/rails-email-error-530-5-5-1-authentication-required

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