ruby-on-rails – ActionMailer的电子邮件“发送”在development.log中,但未收到

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – ActionMailer的电子邮件“发送”在development.log中,但未收到前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在本地主机上使用Rails 2.3.2和 Ruby 1.8.6,通过ActionMailer实际发送问题. development.log表示它已发送电子邮件没有错误,但电子邮件没有收到.我已经尝试了多个电子邮件地址发送和接收,并尝试了多个配置和插件,但无法发送电子邮件.任何帮助将非常感激 – 我觉得我正在围绕不同版本的轨道和红宝石的一堆版本的解决方案跳舞,并且不能解决它.我非常感谢任何意见.谢谢!

插件

>动作邮件可选tls
> smtp_tls

不同的电子邮件配置:

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',: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:

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

解决方法

将以下内容放在config / environments / development.rb中
config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = true

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

另外对于2.X轨,你需要设置:

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
}
原文链接:https://www.f2er.com/ruby/271956.html

猜你在找的Ruby相关文章