5

In /Mage/Sales/Model/Order.php +/- line 1263 public function sendNewOrderEmail()

It uses $mailer to send the mail.

I would like to get the HTML content that is in the email send by $mailer.
For example with: $mailer->toHtml()

How can I do this?

2

Try $text = $mailer->getProcessedTemplate($variables); where $variables is an array which is to be replaced in template. If you do not have the variables or want to get the text content of the mail after it is sent, then you can do $mail = $mailer->getMail(); $text = $mail->getBodyHtml(); where $email is instance of Zend_Mail, which yo can look into to see what else you can get.

  • Thanks Petar, but I'm not sure I understand. I've tried (after: $mailer->send();) all your options but also: $mailer->getBodyText()->getRawContent() and it's not giving any output... Anymore hints where to look for...? thanks! – Bob van Luijt Nov 6 '13 at 9:30
  • You should get $mail object out of mailer, and from $mail take $mail->getBodyText() – Petar Dzhambazov Nov 6 '13 at 21:21
  • I'm sorry, but I don't get it :-S I have $mailer->send(); then $mail = $mailer->getMail(); and then $mail->getBodyText(); and $mail->getBodyText() = empty. Thank! – Bob van Luijt Nov 11 '13 at 9:10
  • Then try $mail->getBodyHtml(); templates are not automatically added as plain text – Petar Dzhambazov Nov 13 '13 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.