developer tip

Net :: SMTPAuthenticationError when send email from Rails app (on 스테이징 환경)

optionbox 2020. 9. 2. 17:38
반응형

Net :: SMTPAuthenticationError when send email from Rails app (on 스테이징 환경)


Rails 애플리케이션에서 이메일을 보내고 있습니다. 개발 환경에서는 잘 작동하지만 스테이징에서는 실패합니다. 다음과 같은 오류가 발생합니다.

Net::SMTPAuthenticationError (534-5.7.14 <https://accounts.google.com/ContinueSignIn?plt=AKgnsbtdF0yjrQccTO2D_6)

스테이징을위한 도메인 이름이 없습니다.

staging.rb의 설정은 다음과 같습니다.

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "my.ip.addr.here:80" }
config.action_mailer.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => 'my.ip.addr.here:80'
      :user_name => "my_email_name@gmail.com",
      :password => "my_email_password",
      :authentication => 'login'
}

도와주세요.

편집하다.

:tls => true옵션을 추가 하면

OpenSSL::SSL::SSLError (Unrecognized SSL message, plaintext connection?)

그런 다음 포트를 25로 변경했는데 이제 다음과 같이 표시됩니다 (30 초 지연).

Timeout::Error (execution expired)

나는 똑같은 문제가 있었다 : 이메일은 개발에서 보내졌지만 프로덕션에서는 보내지지 않았다 Net::SMTPAuthenticationError. 이로 인해 문제가 내 앱의 구성이 아니라 Google에 있다는 결론에 도달했습니다.

이유 : Google이 알 수없는 위치에서의 액세스를 차단했습니다 (프로덕션중인 앱).

해결 방법 : http://www.google.com/accounts/DisplayUnlockCaptcha로 이동하여 계속을 클릭합니다 (새 앱 등록을 위해 10 분 동안 액세스 권한이 부여됨). 이 후 프로덕션에서 내 앱이 이메일을 보내기 시작했습니다.)


이 솔루션은 저에게 효과적입니다.

config.action_mailer.delivery_method = :smtp
  config.action_mailer.default_url_options = { host:'localhost', port: '3000' }
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"
  config.action_mailer.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => 'localhost:3000',
      :user_name => "xyz@gmail.com",
      :password => "password",
      :authentication => :plain,
      :enable_starttls_auto => true
  }

Google이 귀하의 로그인 시도를 차단하는 것은 사실이지만 https://www.google.com/settings/security/lesssecureapps 에서 설정을 변경하여 귀하의 계정이 더 이상 최신 보안 표준에 의해 보호되지 않도록 할 수 있습니다.


해결되었습니다! 나는 단순히 암호를 변경 한 내 Gmail 계정과 어떻게 든 오류가 사라졌다.

수십 가지 변경 후 최종 설정은 다음과 같습니다.

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "my.ip.addr.here" }
config.action_mailer.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => 'my.ip.addr.here:80',
      :user_name => "my_email_name@gmail.com",
      :password => "my_email_password",
      :authentication => :plain,
      :enable_starttls_auto => true
}

다음 링크로 이동하여 https://www.google.com/settings/security/lesssecureapps를 켜십시오.


The above solution provided the correct settings (which I already had) but did not solve the issue. After continued attempts, I kept getting the same error. Turns out, I had to "clear the CAPTCHA" from the web. See the gmail documentation for details.

You can also jump right to the "clear the CAPTCHA" page here.


A lot later but just in case it helps anyone.. Just called Google Apps Help Center and they instructed to change the lesssecureapps setting (as everyone else) but also to change the port to 465.

In my case, that did the trick!


Hello this also worked for me and so if someone is still having a problem try this out.

Make sure you have figaro in your gemfile. To save sensitive information such as username and password as environment variables

gem 'figaro'

And in your config/environments/development.rb , paste the codes below using smtp as method delivery

 config.action_mailer.delivery_method = :smtp

SMTP settings for gmail

  config.action_mailer.smtp_settings =
  {
    :address=> "smtp.gmail.com",
    :port => 587,
    :user_name => ENV['gmail_username'],
    :password=> ENV['gmail_password'],
    :authentication=> "plain",
    :enable_starttls_auto=>true
  }


config.action_mailer.default_url_options = { host: "locahost:3000" }

In your config directory create a file called application.yml and add the codes below.

gmail_username: 'example@gmail.com' 
gmail_password: "your_example_email_password_here"

You must use your email and password for authentication in the file.


I also faced the problem, and after some research in Gmail setting, I found the solution:

  1. In gmail, go to settings.

  2. Select "Forwarding and POP/IMAP" tab.

  3. In the IMAP access section, select "Enable IMAP".


The accepted answer seems very old, I don't know if at that time the followin (better) solution was existing:

Now, sending emails works perfectly!


I had the same problem.


Solution:


I had the same problem and after some trial and errors, have come to this resolution which is an option to be enabled in google:

Click https://www.google.com/settings/u/0/security/lesssecureapps

Enable 'Access for less secure apps' here by logging in with the email address you have provided in smtp configuration.

참고URL : https://stackoverflow.com/questions/18124878/netsmtpauthenticationerror-when-sending-email-from-rails-app-on-staging-envir

반응형