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?
Asked
Active
Viewed 780 times
2 Answers
3
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 => "sender@me.com"
def my_email
mail(:to => "destination@you.com", :subject => "Mail Subject")
end
end
you would do
mail_content = MyMailer.my_email.to_s

eugen
- 8,916
- 11
- 57
- 65