If you’re developing an email send action, or using the default send-email action in WFFM, you probably want to test it out before you send it to the world.  If you’re working locally, then a great idea is to use SMTP4Dev to test things out.  This allows you to see the email in context by listening for emails to come across a certain port (default is 25).

What if you want to do this on a remote server?  You won’t likely be logged in, so you can’t actually see what the email is looking like.  But, there is a way!  Out of the box, WFFM uses a pipeline for sending emails.  These pipelines do a couple things: Expand the Tokens, set attachments, Expand Links, and a few others.  This all occurs in the processMessage pipeline below:

Looking at the highlighted line above, you can see the final step in the process is to send the email.  What if we replaced that with a debug processor? I like XML for this, since it can organize data into a way that is easy to visually diagnose.  Check out this processor:

That looks like a bunch of code, doesn’t it?  It’s not too bad.  First we’re going to snag the Temp Folder from Sitecore. Then we’ll drop in a MailLog folder to organize things. After that, we just write the attributes of the email to the XML and we’re done.  We patch this in via a simple config below:

Btw, I gave myself a gold start for the boolean expression in the patch:instead.  I’d not had to do that before and wasn’t 100% sure it would work. It did though!

If you have any issues with this code, let me know in the comments below.