【问题标题】:Action Mailer Confirmation Emails - Ruby on RailsAction Mailer 确认电子邮件 - Ruby on Rails
【发布时间】:2010-04-29 03:09:09
【问题描述】:

我已经成功安装了来自 ThoughtBot 的Clearance Gem。 Clearance 在新注册时发送确认电子邮件并建议添加:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

到您的 /environments/test.rb 和 development.rb。这个我也试过了

config.action_mailer.default_url_options = { :host => '127.0.0.1', :port => 3000 }

但似乎无法让 rails 发送电子邮件。由于我是 Ruby 和 Rails 的新手,我想知道 ThoughtBot 是否假设我已经完成了一些步骤/配置来发送电子邮件。

我做错了什么/错过了什么?

更新: 刚刚添加了notifier.rb

class Notifier < ActionMailer::Base
 def signup_notification(recipient)
  recipients recipient.email_address_with_name
       bcc        ["example@gmail.com"]
       from       "example@example.com"
       subject    "New account information"
       body       :account => recipient
     end

end

【问题讨论】:

  • 您是否忘记粘贴通知程序中的一些行?没有函数声明。
  • 我只是使用来自:api.rubyonrails.org/classes/ActionMailer/Base.html的代码
  • 你忘记了def signup_notification(recipient)
  • 啊,刚刚加了,还是不行。
  • 也许我需要一个“to”行?到“user.email”?

标签: ruby-on-rails ruby email actionmailer


【解决方案1】:

我必须生成用户邮件模型。

script/generate mailer UserMailer

【讨论】:

    猜你喜欢
    • 2013-05-21
    • 2013-04-14
    • 2014-04-06
    • 2015-08-23
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多