Reputation: 516
In our custom sales app our users are able to send emails based on text partials they choose. We need to record the sent mails in an activity model. How do I get the mailer result as a string in order to save it?
Upvotes: 1
Views: 837
Reputation: 9226
Instead of calling the deliver method to send the mail, you can capture the email message by calling to_s. For example, if you have a mailer:
class MyMailer < ActionMailer::Base
default :from => "[email protected]"
def my_email
mail(:to => "[email protected]", :subject => "Mail Subject")
end
end
you would do
mail_content = MyMailer.my_email.to_s
Upvotes: 3