尝试在RoR应用程序中发送电子邮件时遇到SMTP错误

艾比斯·阿里亚(Abhas arya)

我一直在拼命尝试使用RoR中的Action Mailer类发送电子邮件,即使终端显示正在发送消息,它仍会返回此错误:

 et::SMTPAuthenticationError: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtOS

from /Users/abhasarya/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:968:in `check_auth_response'
from /Users/abhasarya/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:739:in `auth_plain'
from /Users/abhasarya/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:731:in `authenticate'...

这是我的mailer类在app / mailers / my_mailer.rb中的样子:

class MyMailer < ActionMailer::Base
  default from: "[email protected]"

  def welcome_email(user) 
    @user = user

        mail(to: user.email,
             from: '[email protected]',
             subject: 'Welcome!')
  end
end

这是我的config / application.rb文件的样子:

config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {

        address:              'smtp.gmail.com',
        port:                 587,
        #domain:               'gmail.com',
        user_name:            '[email protected]',
        password:             'my_password',
        authentication:       'plain',
        enable_starttls_auto: true  

        }

        config.action_mailer.default_url_options = {
            :host => "localhost",
            :port => 3000
        }

在我的config / environments / development.rb文件中,我也有这两行:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true

我的问题是,每当我启动rails控制台(在开发中工作,不知道如何在生产中运行)时,都将用户的电子邮件分配给user变量,然后输入以下命令: MyMailer.welcome_email(user).deliver

终端说:

Rendered my_mailer/welcome_email.html.erb (11.7ms)
  Rendered my_mailer/welcome_email.text.erb (0.5ms)

Sent mail to [email protected] (923.1ms)
Date: Fri, 08 Aug 2014 13:54:38 -0400
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Welcome!
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_53e50eded7355_2b0b8082dbf85068f";
 charset=UTF-8
Content-Transfer-Encoding: 7bit

但是会导致错误。我的观点很简单,以至于我认为不需要在这里包含它们。我拼命尝试了一切,包括解锁Google验证码,但仍然无济于事。非常感谢您的帮助,我所希望的只是将一封电子邮件发送到正确的收件箱。如果您能解决这个问题,我将永远爱您!!!

拉吉

您看到此错误的原因是Google阻止了您的IP。您将需要为此IP启用授权。

转到http://www.google.com/accounts/DisplayUnlockCaptcha,然后单击继续。

然后再次尝试从应用程序发送电子邮件,它应该可以工作。您需要在访问上述链接的10分钟内从您的应用发送电子邮件。通过访问以上链接,Google将授予10分钟的注册新应用的权限。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

发送SMTP电子邮件在控制台应用程序中被强制关闭,然后才能在.NET中发送电子邮件

尝试在Laravel中发送电子邮件时出错

使用xlwt创建文件并在Django应用程序中发送电子邮件

电子邮件服务器超时错误,我正在尝试从我的应用程序发送和发送电子邮件,但它不起作用

Java从JavaEE应用程序中的不同SMTP服务器发送电子邮件

SMTP错误:534在Golang应用中通过gmail发送电子邮件时出现错误

尝试在 asp.net 核心应用程序中使用 SmtpClient 发送电子邮件时出错

Angular JS从应用程序发送电子邮件

Rails应用程序不发送电子邮件

从AngularJS Web应用程序发送电子邮件

从 React 应用程序发送电子邮件

以后在RoR中发送电子邮件

在Swift中发送应用程序电子邮件

使用SMTP在Gmail帐户中发送电子邮件

使用SpringBoot应用程序发送SMTP电子邮件

从Android应用程序发送电子邮件时出现NetworkOnMainThreadException

发送电子邮件时,没有应用程序可以执行此操作

在Ionic应用程序中发送电子邮件会导致以下错误:TypeError:$ cordovaEmailComposer.isAvailable不是一个函数

是否可以在不启动相应应用程序的情况下在android中发送电子邮件?

由于 smtp 在 Lambda (python) 中发送电子邮件时出错

通过SMTP Python发送电子邮件时遇到麻烦

我正在尝试通过 nodemailer 发送电子邮件,我已经允许我的谷歌帐户使用不太安全的应用程序,但仍然出现错误

尝试在Django中发送电子邮件时出现TimeoutError

在概念验证Rails应用中发送电子邮件

使用Apple Mail应用程序以外的外部应用程序发送电子邮件

在nodemailer应用程序中使用通过发送电子邮件发送sendgrid会出现以下错误?

当我尝试发送电子邮件时,SMTP服务器需要安全的连接

当我尝试在Android中使用Mandrill SMTP发送电子邮件时出错

尝试通过 SMTP (Java) 发送电子邮件时出现 java.lang.NoClassDefFoundError