使用Devise :: Mailer发送的电子邮件被过滤掉

时间:2015-09-17 02:13:52

标签: ruby-on-rails devise

我有一个使用Devise:Mailer发送电子邮件的rails应用程序。我知道功能有效,因为当我使用“myemail@hotmail.com”创建用户帐户时,我收到一封确认电子邮件,一切都很棒。但是,当我使用“myemail@sfu.ca”(我的大学电子邮件帐户)创建帐户时,即使邮件已正确发送,电子邮件也无法到达我的邮箱。它也不在垃圾文件夹中。

我正在使用Gmail帐户发送电子邮件并使用端口号为587的SMTP。以下是development.rb中的设置:

config.action_mailer.smtp_settings = {
  :address              => 'smtp.gmail.com',
  :port                 => 587,
  :domain               => 'gmail.com',
  :user_name            => 'MYEMAIL@gmail.com',
  :password             => 'password',
  :authentication       => 'plain',
  :enable_starttls_auto => true

}

我不确定这是否是我发送电子邮件的方式的问题,或者问题出在电子邮件服务端(即他们阻止电子邮件中有些模糊的事情)。有没有办法将您的电子邮件标记为“安全”,就像使用某种类型的证书的java在线小程序一样?或者某些邮件提供商是否无法接受这些电子邮件?

编辑: 将这两行添加到development.rb

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

我收到的关于电子邮件的输出是:

Devise::Mailer#confirmation_instructions: processed outbound mail in 182.4ms

Sent mail to myemail@sfu.ca (967.5ms)
Date: Sun, 20 Sep 2015 21:51:24 +0000
From: myemail@gmail.com
Reply-To: myemail@gmail.com
To: myemail@sfu.ca
Message-ID: <55ff2a5ca51dc_a953f93e3165664988bc@myproject-123456.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome myemail@sfu.ca!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://myproject-123456.nitrousapp.com:3000/users/confirmation?confirmation_token=-PAuFJbLVcaDH-FG6">Confirm my account</a></p>

Redirected to http://myproject-123456.nitrousapp.com:3000/users/sign_in
Completed 302 Found in 1378ms (ActiveRecord: 2.5ms)


Started GET "/users/sign_in" for 54.244.95.60 at 2015-09-20 21:51:25 +0000
Cannot render console from 54.244.95.60! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::SessionsController#new as HTML
  Rendered .bundle/gems/devise-3.4.1/app/views/devise/shared/_links.html.erb (1.1ms)
  Rendered .bundle/gems/devise-3.4.1/app/views/devise/sessions/new.html.erb within layouts/application (8.6ms)
  Rendered layouts/_navigation.html.erb (1.5ms)
Completed 200 OK in 201ms (Views: 198.6ms | ActiveRecord: 0.0ms)

编辑#2:

解决了这个问题。问题是我的domain属性设置为gmail.com,而我是从http://myproject-123456.nitrousapp.com:3000/发送的,因此域必须是nitrousapp.com

新设置为:

config.action_mailer.smtp_settings = {
  :address              => 'smtp.gmail.com',
  :port                 => 587,
  :domain               => 'nitrousapp.com',
  :user_name            => 'MYEMAIL@gmail.com',
  :password             => 'password',
  :authentication       => 'plain',
  :enable_starttls_auto => true

}

1 个答案:

答案 0 :(得分:0)

我认为这是您创建新的Google帐户设置的身份验证问题。

有一些要点可以检查您的Google帐户设置 -

  1. 在Google帐户中关闭双向身份验证。
  2. 首先找出问题。在development.rb中添加这些

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