Mailer Broken from Controller
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')
精彩评论