views:

182

answers:

4

Just using the standard cfmail tag, is there a way we can confirm that the email has been sent?

I tried cftry/cfcatch but that only confirms that there were no errors in processing the tag, if I put in an invalid mail server, it passes (but mail obviously doesnt send)

+1  A: 

If it is not in the spool folder, and not in the error log, it has been sent.

see: Using ColdFusion with mail servers

Henry
this is on a hosted server so I dont know if I will have the correct access
Tim
well, that's how CFMail works. So.. :)
Henry
The only real way to tell is to consult the email server's log files. ColdFusion simply hands the email message off to the mail server. If the mail server has a problem sending it, then CF doesn't know about it. Don's BCC hack for important stuff is a possible temp solution.
David Collie
A: 

You can always write a routine to check the mail log. That requires you to have access to the log files.

Gert G
+5  A: 

One hackish way, if do not have access to the logs, is to bcc an alternate address.

Don
A: 

If you turn off spooling the messages to disk, they'll attempt to be sent immediately. Then you can trap with try/catch which should let you log any SMTP errors. If you don't get an error then you are reasonably assured that the message was sent successfully.

This may have negative ramifications for performance under load. It will also negatively impact the user experience as the user will be waiting for the SMTP negotiation that usually takes place in the background. You might then consider using CFTHREAD, but then why not just use the native spooling?

Al Everett