代码之家  ›  专栏  ›  技术社区  ›  bradgonesurfing

使用Gmail从铁路上收到的确认电子邮件3未送达

  •  7
  • bradgonesurfing  · 技术社区  · 15 年前

    我已经安排了后续工作。

    ----------------------
    config/environments/development.rb
    ----------------------
     29   ActionMailer::Base.delivery_method = :smtp
     30   ActionMailer::Base.perform_deliveries = true
     31   ActionMailer::Base.raise_delivery_errors = true
     32  
     33   ActionMailer::Base.smtp_settings = {
     34     :enable_starttls_auto => true,  #this is the important stuff!
     35     :address        => 'smtp.gmail.com',
     36     :port           => 587,
     37     :domain         => 'foo.com',
     38     :authentication => :plain,
     39     :user_name      => '---@---.---',
     40     :password       => '---'
     41   }
    

    但是,当designe发送确认邮件时,webbrick会打印出来。 日志中的电子邮件没有错误,但电子邮件不会结束 在我的收件箱或垃圾邮件收件箱中。

    有什么想法吗?

    编辑:

    I now get
    
        Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. x13sm2646038bki.0
    

    ):

    我发现了

    ----------------------
    config/environments/development.rb
    ----------------------
     17   # Don't care if the mailer can't send
     18   config.action_mailer.raise_delivery_errors = false
    

    在配置文件中设置得更高。但是,发出starttls命令的原因是什么?

    解决方案:

    ----------------------
    config/environments/development.rb
    ----------------------
     26   require 'tlsmail' #key but not always described
     27   Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
     28  
     29   ActionMailer::Base.delivery_method = :smtp
     30   ActionMailer::Base.perform_deliveries = true
     31   ActionMailer::Base.raise_delivery_errors = true
     32  
     33   ActionMailer::Base.smtp_settings = {
     34     :enable_starttls_auto => true,  #this is the important stuff!
     35     :address        => 'smtp.gmail.com',
     36     :port           => 587,
     37     :domain         => 'xtargets.com',
     38     :authentication => :plain,
     39     :user_name      => '-------',
     40     :password       => '-------'
     41   }
     42  
    

    布拉德

    2 回复  |  直到 15 年前
        1
  •  5
  •   Alberto Santini    15 年前

    我也有同样的问题;在我的例子中,是由于一个错误(net::smtp不怎么说tls,这是gmail所要求的),我按照说明解决了它。 here .

        2
  •  0
  •   Paul A Jungwirth Mathew Sachin    14 年前

    您可以将一个额外的参数传递给smtp_设置,而不是全局关闭ssl cert验证:

    config.action_mailer.smtp_settings = {
      :address              => 'smtp.example.com',
      :port                 => '25',
      :domain               => 'example.com',
      :user_name            => 'someone@example.com',
      :password             => 'secret',
      :authentication       => 'plain',
      :enable_starttls_auto => true,
      :openssl_verify_mode  => OpenSSL::SSL::VERIFY_NONE,
    }
    

    您可能还需要 require 'openssl' 得到这个常数。

    此解决方案也适用于 Pony ,如果包括 :openssl_verify_mode :via_options 搞砸。