ActionMailer在开发中“发送”电子邮件。日志,但没有收到

时间:2023-01-16 10:19:32

I'm having problems actually sending via ActionMailer in development, on my localhost, with Rails 2.3.2 and Ruby 1.8.6. The development.log shows that it has "sent" the email with no errors, but the email is not received. I have tried multiple email addresses for sending and receiving and have tried multiple configs and plugins, but cannot get the email to send. Any help would be much appreciated - I feel like I'm dancing around a bunch of versions of solutions for different versions of rails and ruby and can't nail it down. I would much appreciate any comments. Thanks!

在开发中,我在我的本地主机上有Rails 2.3.2和Ruby 1.8.6通过ActionMailer发送的问题。的发展。日志显示它已经“发送”了邮件,没有错误,但是没有收到邮件。我尝试过发送和接收多个电子邮件地址,也尝试过多个配置文件和插件,但无法发送电子邮件。如果有任何帮助,我将非常感激——我感觉自己在为不同版本的rails和ruby寻找各种不同版本的解决方案,却无法确定。如有任何意见,我将不胜感激。谢谢!

Plugins:

插件:

  • action mailer optional tls
  • 行动梅勒可选的tls
  • smtp_tls
  • smtp_tls

Different email configs:

不同的电子邮件配置:

  ActionMailer::Base.smtp_settings = {
    :enable_starttls_auto => true, #works in ruby 1.8.7 and above
    :address => 'smtp.gmail.com',
    :port => 587,
    :domain => 'example.com',
    :authentication => :plain,
    :user_name => 'testacct',
    :password => 'secret'
  }

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :tls => :true,
    :address => 'smtp.gmail.com',
    :port => 587,
    :authentication => :plain,
    :user_name => 'testacct@gmail.com',
    :password => 'secret'
    #:enable_starttls_auto => true # for rails >= 2.2 && ruby >= 1.8.7
  }
  config.action_mailer.perform_deliveries = :true #try to force sending in development 
  config.action_mailer.raise_delivery_errors = :true 
  config.action_mailer.default_charset = "utf-8"

Development.log:

Development.log:

Sent mail to sa23kdj@trash2009.com

Date: Fri, 18 Dec 2009 00:27:06 -0800
From: Test Email Acct <testacct@gmail.com>
To: sa23kdj@trash2009.com
Subject: Signup
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4b2b3cda9088_634334302a5b7


--mimepart_4b2b3cda9088_634334302a5b7
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww=
w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang=3D'en' xml:lang=3D'en' xmlns=3D'http://www.w3.org/1999/xhtml'>=

  <head>
    <meta content=3D'text/html;charset=3DUTF-8' http-equiv=3D'content-typ=
e' />
  </head>
  <body>
    Welcome Email
    <p>
      user name:
      lfglkdfgklsdf
      activation link:
      http://localhost:3000/login
    </p>
  </body>
</html>

--mimepart_4b2b3cda9088_634334302a5b7--

3 个解决方案

#1


14  

Put the following in config/environments/development.rb

在配置/环境/开发中添加以下内容。

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

It will override the settings in config/environment.rb

它将覆盖config/environment.rb中的设置。

Also for rails 2.X you'll need to setup:

也为rails 2。你需要安装:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,  
  :address        => "smtp.gmail.com",
  :port           => 587,
  :domain         => "domain.com",
  :user_name      => "username@domain.com",
  :password       => "secret_passsword",
  :authentication => :plain
}

#2


8  

You need to use true and not :true.

你需要用true和not:true。

:tls => true
...
config.action_mailer.perform_deliveries = true #try to force sending in development 
config.action_mailer.raise_delivery_errors = true 

#3


4  

In case anyone faces this problem, set "config.action_mailer.raise_delivery_errors = true" in development.rb in your environments folder and try sending mail again. This should raise whatever error is being encountered.

如果有人遇到这个问题,请设置“config.action_mailer”。在开发中,raise_delivery_errors = true。在“环境”文件夹中的rb并尝试再次发送邮件。这应该会引起所遇到的任何错误。

Sometimes in line 8 of smtp_tls.rb , the check_auth_args method accepts only 2 arguments : user and secret. Remove the 'authtype' argument if you see it and try again. Should work.

有时在smtp_tls的第8行。check_auth_args方法只接受两个参数:user和secret。如果看到“authtype”参数,请删除它,然后再次尝试。应该工作。

#1


14  

Put the following in config/environments/development.rb

在配置/环境/开发中添加以下内容。

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

It will override the settings in config/environment.rb

它将覆盖config/environment.rb中的设置。

Also for rails 2.X you'll need to setup:

也为rails 2。你需要安装:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,  
  :address        => "smtp.gmail.com",
  :port           => 587,
  :domain         => "domain.com",
  :user_name      => "username@domain.com",
  :password       => "secret_passsword",
  :authentication => :plain
}

#2


8  

You need to use true and not :true.

你需要用true和not:true。

:tls => true
...
config.action_mailer.perform_deliveries = true #try to force sending in development 
config.action_mailer.raise_delivery_errors = true 

#3


4  

In case anyone faces this problem, set "config.action_mailer.raise_delivery_errors = true" in development.rb in your environments folder and try sending mail again. This should raise whatever error is being encountered.

如果有人遇到这个问题,请设置“config.action_mailer”。在开发中,raise_delivery_errors = true。在“环境”文件夹中的rb并尝试再次发送邮件。这应该会引起所遇到的任何错误。

Sometimes in line 8 of smtp_tls.rb , the check_auth_args method accepts only 2 arguments : user and secret. Remove the 'authtype' argument if you see it and try again. Should work.

有时在smtp_tls的第8行。check_auth_args方法只接受两个参数:user和secret。如果看到“authtype”参数,请删除它,然后再次尝试。应该工作。