Rails从一个邮件程序功能发送2封不同的电子邮件 [英] Rails Send 2 different emails from one mailer function

查看:67
本文介绍了Rails从一个邮件程序功能发送2封不同的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有必要这样做,因为在我看来这是合乎逻辑的:

I have a need to do so, because it seems logical to me:

def notification(vehicle) 
   @vehicle = vehicle

   mail(:to => @vehicle.owner.email_address, :template_name => "n_o")
   mail(:to => @vehicle.booker.email_address, :template_name => "n_b")

end

问题是:我只收到最后电子邮件。因此,在上面的示例中,只有预订者会收到电子邮件,而没有任何内容发送给所有者。

The problem is: I'm receiving only the last e-mail. So, in my example above, only the booker would receive the email and nothing is being sent to the owner.

出了什么问题?怎么解决呢?我应该创建两个单独的邮件发送功能,例如notification_owner(车辆)和Notification_booker(车辆),还是有一个更简单的解决方案?

What is the problem ? How to solve it ? Should I create two separate mailing functions, like notification_owner(vehicle) and notification_booker(vehicle), or there is a simplier solution ?

谢谢!

推荐答案

好。所以,愚蠢的我,我忘了提到我正在处理delay_jobs宝石。因此,问题是我忘记指定 .deliver!。每个邮件功能后的操作。

Ok. So, silly me, I forgot to mention that I'm dealing with delayed_jobs gem. So, the problem was, that I forgot to specify the ".deliver!" action after each "mail" function.

因此,它应该看起来像这样:

So, it should look like this:

mail(:to => @vehicle.owner.email_address, :template_name => "n_o").deliver!
mail(:to => @vehicle.booker.email_address, :template_name => "n_b").deliver!

但还是。谢谢您的支持!

But still. Thank you for your support!

这篇关于Rails从一个邮件程序功能发送2封不同的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆