我想知道如何有条件地放弃在ActionMailer操作本身中发送邮件.
class SomeMailer < ActionMailer::Base ... def some_emails some_models = Model.where(:a => 1) if !some_models.blank? mail(...) else # What to add here? # render :nothing => true doesn't work end end end
现在通过SomeMailer.some_emails.deliver调用这个!返回
ArgumentError:发送消息所需的发送方(Return-Path,Sender或From)
解决方法
而是把你的条件放在你打电话给SomeMailer.some_emails.deliver的地方!