【问题标题】:Rails ActionMailer receive method does nothingRails ActionMailer 接收方法什么都不做
【发布时间】:2016-04-29 05:58:27
【问题描述】:

我正在关注关于action mailer receive method 的Rails 官方文档并使用rails runner 'UserMailer.receive(STDIN.read)' 命令进行测试,但没有任何反应

class UserMailer < ActionMailer::Base
  add_template_helper EmailHelper
  default from: "xx@xxx.xxx"

  def user_created(params)
    @user = User.find params[0]
    @creator = User.find params[1]
    if @user && @creator
        mail(to: @user.email, subject: "......").deliver
    else
        logger.info "......"
    end
  end

  def receive(email)
    puts YAML::dump email
  end
end

这是我的 Rails 应用程序的详细信息

rails@4.1.6
actionmailer@4.1.5

UserMailer 实际发送邮件但收不到邮件。有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails ruby actionmailer


    【解决方案1】:

    我想你想参考 Action Mailer 基础指南:http://guides.rubyonrails.org/action_mailer_basics.html#receiving-emails

    我将他们的建议解释为:将您的邮件服务器/进程配置为“管道”到 Rails 运行器脚本......这将解释 STDIN.read;邮件消息的内容将被传递到脚本中。

    HTH。

    【讨论】:

      猜你喜欢
      • 2011-02-16
      • 2010-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-07
      • 2015-01-13
      • 1970-01-01
      相关资源
      最近更新 更多