我正在尝试使用PostMarkApp和Rails get (postmark-rails、postmark-gem和mail)将我系统的所有电子邮件通知整合到一个保护伞下。我已经成功地创建了一个邮件程序,可以处理购物收据的发送,但我还无法收到忘记密码的电子邮件。我的开发日志显示Devise发送了消息,但我的收件箱中没有收到电子邮件,PostMark积分也没有减少。
通过我的PostMark帐户发送Devise的邮件的最好或最简单的方式是什么?
来自config/environments/development.rb的代码片段
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => "VALID_API_KEY_WAS_HERE" }
config.postmark_signature = VALID_POSTMARK_SIGNATURE_WAS_HERE
使用邮戳的我的邮件程序
class Notifier < ActionMailer::Base
# set some sensible defaults
default :from => MyApp::Application.config.postmark_signature
def receipt_message(order)
@order = order
@billing_address = order.convert_billing_address_to_hash(order.billing_address)
mail(:to => @order.user.email, :subject => "Your Order Receipt", :tag => 'order-receipt', :content_type => "text/html") do |format|
format.html
end
end
end
编辑:我的问题的解决方案在下面
通过让我的Notifier
邮件程序扩展Devise::Mailer并指定Devise在config/initializers/devise.rb
中使用我的通告程序作为邮件程序,解决了这个问题
来自config/initializers/devise.rb的代码片段
# Configure the class responsible to send e-mails.
config.mailer = "Notifier"
我的通告邮件程序now
class Notifier < Devise::Mailer
# set some sensible defaults
default :from => MyApp::Application.config.postmark_signature
# send a receipt of the Member's purchase
def receipt_message(order)
@order = order
@billing_address = order.convert_billing_address_to_hash(order.billing_address)
mail(:to => @order.user.email, :subject => "Your Order Receipt", :tag => 'order-receipt', :content_type => "text/html") do |format|
format.html
end
end
# send password reset instructions
def reset_password_instructions(user)
@resource = user
mail(:to => @resource.email, :subject => "Reset password instructions", :tag => 'password-reset', :content_type => "text/html") do |format|
format.html { render "devise/mailer/reset_password_instructions" }
end
end
end
https://stackoverflow.com/questions/5679571
复制相似问题