I would like to know if its possible to see the final raw html code that is sent out (before it gets processed by an email client)
along with headers and everything.
this would be a huge help for designers like me.
i'm using htmlmail to send out simplenews newsletters and there is a lot of processing going on in all kinds of modules
before it gets sent.
even if its something that could be in a debug or test mode it would be of huge help
thanks!

Comments

pillarsdotnet’s picture

Assigned: Unassigned » pillarsdotnet
blasthaus’s picture

For example in Simplenews I'm using a simple drupal_set_message after the $body variable is built which just spits out the html as a message. This is very helpful for styling the message. Additionally it would be great to do something similar just after the emogrifier class does it's magic.

pillarsdotnet’s picture

The way to do it would be to write a special MailSystemInterface class whose implementation of the mail() method just captures the output for later viewing. The format() method would then call HTMLMailSystem::format().

I could write the back-end code in fifteen minutes; the UI would take a bit longer. It's on my to-do list.

On the other hand, previewing in a browser is a poor indication of what the message will look like when viewed by the recipient mail program. A better way to do things would be to send a test newsletter to a test account and view the results that way.

blasthaus’s picture

Great, yea I use litmus.com for testing btw. And just to be clear the drupal_set_message spits out raw html text which is good enough for me. that's where I can intercept the markup and copy/paste into a document to tweak the css. thanks huge!

greenskin’s picture

I need to implement a preview for my email message. I'm extremely new to Drupal 7's mail system. Can you quickly share a chunk of code for how I can render a preview?

blasthaus’s picture

well like @pillarsdotnet said, what you may see in a preview on a webpage is not going to be an accurate preview for an email client. Above in comment #3, he describes how to go about this.

what i was after was essentially getting the full html code of the mail that gets sent. this may be possible to just use watchdog to send the html output as a string right before it gets sent via mail, so after you test it, you can look in the logs, copy and paste the html code into a text editor, save it and open in a web browser. it's cumbersome but should work.

fyi i ended up solving this pretty much outside of htmlmail entirely although i did use the echo module. it involved a custom module which was essentially a form where you create a newsletter by selecting nodes by content type and theme them with template files for various <table> -based html markup like 1-row, 2-row, 3-row, 4-row which makes a summary for each node and uses imagecache for the different nodes' images. Note the full html markup was previously extensively tested in Litmus across all browsers. Then for the Drupal preview, I used an ajax callback on the form to generate a new pop-up page with the full html of the mail and the codefilter module to capture the html code in a text area to copy and paste into a bulk mail sender. (wow, that was a mouthful!) probably not something you want to try but it works :-)

anybody’s picture

+1 for this idea. We'd need the same for some quick checks.

tr’s picture

Version: 7.x-2.43 » 8.x-3.x-dev
Assigned: pillarsdotnet » Unassigned
Issue summary: View changes
Status: Active » Postponed

New features need to go into the current version (8.x-3.x) first. If you would like to see this feature implemented, please provide a patch - the maintainers of this module will not be working on this.

tr’s picture

Status: Postponed » Closed (won't fix)