So, as I woke up this morning on my uncomfortable new pillows, I was thinking about the things I had to accomplish today. I am heading to work late, so I thought I’d get an early start while at home, which meant waking up at the same time as usual… though it doesn’t give me the morning drive to actually get my mind going. Luckily for me, new overstuffed pillows that make my sleep uncomfortable kept me from wanting to stay in bed. So, I thought more about the continuing log saga and what I was going to write today.
ColdFusion programming has a function that I use in every project, CFMAIL. Whether it’s a mailer application or just sending myself a note that something didn’t work like it was supposed to, I send mail in every application. What happens during a CFMAIL? Well, a little text file is created with all the proper mail headers and put into ColdFusion’s /mail/spool folder, where it’s nicely picked up by whatever mailing system you have on your system. If the mail doesn’t go out, for whatever error, it is thrown into the /mail/undeliverables/ folder and a log entry is written:
“Error”,”scheduler-0″,”04/16/08″,”18:12:34″,,”Invalid Addresses; nested exception is: class javax.mail.SendFailedException: 550 5.1.1 <firstname.lastname@example.org> User unknown; rejecting “
This error occurred in our logs (the address was modified to protect the innocent programmers) because the email address that was used had a domain that was on our server, but not the user, which then caused our mail server to reject the mail. In this case, after reading the log, we can go into the failed emails stored in the undeliverables folder, reset the names and throw them back into the spool, and will send out just fine. Usually though, the mail errors have to do with incomplete email addresses and poor error checking.
If you’re not doing proper address checking, your mail could wind up in here as well, such as if you have a form field where the user supplies an email address and the user types in a ,com or just the domain without a user. “Error”,”scheduler-5″,”04/11/08″,”11:25:10″,,”501 5.5.2 <Webquote>… Domain name required ”
I used to use a basic regular expression to validate the emails, but since ColdFusion MX 7, there is a new function ‘isValid’ which can do what I always had to look up again to do. At least this way there will be fewer bad emails, except for those days the mail server goes bonkers.