开发者

Mailer Broken from Controller

开发者 https://www.devze.com 2023-03-16 15:51 出处:网络
So I\'ve written a mailer entitled UserMailer containing a method entitled test.The method accepts two parameters: user (object) and recipient (email).

So I've written a mailer entitled UserMailer containing a method entitled test. The method accepts two parameters: user (object) and recipient (email).

From the console I can send the mailer with the command UserMailer::deliver_test(User.find(1), 'email@email.com') and the email开发者_运维知识库 sends successfully.

But if I define a the same command or its counterpart UserMailer.test(User.find(1), 'email@email.com').deliver in users#mail, accessing the action via users/mail returns nothing.

What do I have to do for the controller to trigger delivery properly?


You just need to call the mailer's class method from inside your controller

UserMailer.deliver_test(User.find(1), 'email@email.com')

or from the user's instance method:

UserMailer.deliver_test(self, 'email@email.com')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号