【问题标题】:Ruby ActionMailer does not sendRuby ActionMailer 不发送
【发布时间】:2014-02-27 16:01:28
【问题描述】:

我正在使用 ActionMailer 发送电子邮件,内部 SMTP 不需要身份验证。所以我的代码很简单:

ActionMailer::Base.mail(
  :from => 'example@...',
  :to   => 'example@...',
  ...
);

但它实际上并不发送电子邮件。我错过了什么吗?

【问题讨论】:

    标签: ruby actionmailer


    【解决方案1】:

    您必须在邮件中调用“交付”。

    ActionMailer::Base.mail(:from => 'sender@example.com', 
                            :to => 'receiver@example.com', 
                            :subject => 'An Email Subject', 
                            :body => 'Thank you for reading').deliver
    

    【讨论】:

    • 嘿史蒂夫,我还有一个问题。那么我可以在我的邮件类中使用 request.env 吗?我收到请求未定义的错误。
    • @user1510412 请求在邮件类中不可用(或者我一直这么理解)。当我需要它时,我会在控制器操作中使用它并将其作为参数之一传递给邮件程序类方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 2013-02-07
    • 2014-12-31
    • 2011-12-31
    相关资源
    最近更新 更多