【问题标题】:Error when trying to send welcome email with Action Mailer?尝试使用 Action Mailer 发送欢迎电子邮件时出错?
【发布时间】:2014-02-18 23:25:08
【问题描述】:

我从 ruby​​ 指南生成了一个动作邮件。但是,当我尝试通过 Heroku 在已部署站点上进行测试运行时,我收到一条错误消息,提示出现问题并检查日志。

我注释掉了要求发送电子邮件并注册的方法工作正常。该电子邮件实际上是一封欢迎电子邮件。我不知道从这里去哪里。

这是来自我的 ActionMailer

default from: "from@example.com"

def welcome_email(user)
  @user = user
  @url ='https://inyourshoes.herokuapp.com/signup'
  mail(to: @user.email, subject: 'Welcome to InYourShoes!')
 end
end

这是来自我的用户控制器

def create
 @user = User.new(user_params)
 if @user.save
  UserMailer.welcome_email(@user).deliver
  sign_in @user 
  flash[:success] = "Welcome to InYourShoes!"
  redirect_to @user  
 else
   render'new'
 end

结束

基本上,我希望在用户成功注册网站后发送一封电子邮件。非常感谢您的帮助

【问题讨论】:

  • 您是否将 smtp 设置添加到 production.rb 中?
  • I'm not sure where to go from here - 检查日志怎么样?
  • 你在使用 Ruby 2.0 吗?
  • @H-man 我把它放在我的开发中,也许这就是原因。我是否也必须将 config.action_mailer.raise_delivery_errors = true 放在那里?
  • @BroiSatse 我不知道如何检查,我进入了我的 heroku 帐户,在设置中它什么也没显示

标签: ruby-on-rails ruby email heroku


【解决方案1】:

假设您使用的是 Ruby >= 2.0,请尝试:

default({from: "from@example.com"})

否则:

default({ :from => "from@example.com" })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 2016-08-04
    • 2015-08-23
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多