Jump to content

Tools for debugging calls to mail()?


jhsachs

Recommended Posts

I'm writing code that sends a moderately complex email (HTML and plain text parts, and an attachment). This is the first time I've worked with MIME headers, and I anticipate a difficult time getting the output right. The testing cycle will be slowed down by the fact that each test will require sending an email and waiting for it to arrive. Then I'll have to deduce what is wrong from the behavior of the mail reader, which is essentially a black box.

 

Are there any tools which will improve the process, for example, by analyzing a set of mail() parameters and telling me whether they conform to MIME syntax?

Link to comment
Share on other sites

Not sure about tools being available, but in those situations, what I do is:

 

1. Use gmail for testing (emails arrive within 1 second so there's not much waiting time)

2. start with a base that works, and add my stuff gradually, testing after adding every line.

 

instead of writing all the code and then trying to find the problem, I find it easier to add a line at a time, and keep testing, so I always know where the problem is.

 

I know this is not what you asked, but hey, just thought I would shout it out, in case you don't find any cool tools.

 

Hope it helps

Link to comment
Share on other sites

Well, that's not what I asked, but it's probably what I should have asked! I still hope somebody comes up with a tool, but everything you said is practical and helpful.

 

I have to write some moderately complex code to get the flexibility I need, so adding a line at a time isn't practical, but I can debug by calling my mail function with simple requests and work up from there.

Link to comment
Share on other sites

Take a look at hMailServer. At work I use yet another program but I can't find it by a quick search on the net and I can't recall the name.

 

I'll update this topic as soon as I get the name.

 

EDIT: The program's name is Papercut. The website currently returns a 404. Darn.

EDIT 2: It's now hosted on CodePlex: http://papercut.codeplex.com/

Link to comment
Share on other sites

Thank you, Ignace. I'm not sure I'll need hMailServer for this task, but I'll it sounds like a useful tool to keep in my toolkit.

 

Right now my attention is focused on the other end of the process: having sent an email, how can I tell whether it's right? I can imagine a server validating the headers before sending the message, but I didn't see anything in my (very superficial) inspection of hMailServer that suggested such a capability.

 

The ideal tool would receive a message and tell me exactly what, if anything, is wrong with its headers. Failing that, I need to deduce that information from the behavior of a conventional email reader.

 

A simpler but still useful tool would be a mail reader that displays all of the headers "raw." I could use it to display a certain type of message sent from another mail reader, and thus known to be good, and compare its headers to those generated by my code for the same type of message. If I'm careful, I can find any errors that way.

 

I've started debugging, and the first problem I face is: how can I tell whether the plain text component of a message is correctly formatted? My standard mail reader is Eudora, and it apparently has no option for forcing the display of plain text. I need to find a way to display the plain text part of an email that has an HTML part, simulating the behavior of a reader that cannot display HTML.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.