[英]Rails 4 Mailer not sending email
我正在嘗試使用Rails 4發送電子郵件。服務器未引發任何錯誤,但我無法在我的郵箱中收到郵件...這是我的配置:
環境/development.rb
config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_options = {from: 'no-reply@website.com'}
我正在這樣發送電子郵件:
user_mailer.rb
def deliver_password_reset_instructions(user)
mail :to => user.email, :subject => 'Instructions pour la reinitialisation de votre mot de passe'
end
user.rb
def deliver_password_reset_instructions!
reset_perishable_token!
UserMailer.deliver_password_reset_instructions(self)
end
是否有人知道為什么它不發送電子郵件?
您的問題是您正在生成電子郵件,但實際上並未發送 。
UserMailer.deliver_password_reset_instructions(self).deliver
實際上會傳送您正在創建的電子郵件。
閱讀http://guides.rubyonrails.org/action_mailer_basics.html#walkthrough-to-generating-a-mailer (第2.1.4節-調用郵件程序),了解有關如何在應用程序中使用郵件程序的更多詳細信息。
編輯: deliver
已被棄用,在Rails的4.2,有利於任deliver_now
或deliver_later
。 為了實現與從先前版本的Rails中進行deliver
相同的行為,您應該使用deliver_now
- deliver_later
旨在與ActiveJob和后台作業處理器一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.