The reason I wrote this article in English is that all these problems occured in English environment. You can reprint this article freely as long as you link back to http://www.techmemo.net/704.html/
These problems have bothered me for almost a whole day, and I finally got everything fixed now.
I ran into the error early this morning when I answered one of my clients’ ticket in WHMCS, the mail didn’t got through, it gave me an “Email Sending Failed – Could not instantiate mail function” error, I searched google for a few hours but none of them were really helping. So I decided to troubleshoot this by myself.
I started with checking Plesk’s mail system, well, another weired problem occured, I couldn’t start the website of Horde webmail. It gave me this error: “Value does not fall within the expected range”, I searched google again, but still nothing helped. I felt rather anoyed, I have been held up for almost a day trying to troubleshoot this. But when nothing can help me, I should help myself.
So I installed hMailServer and try to use AtMail instead, but again, I couldn’t start the website of AtMail webmail. Frustrated as I was, I had to find a solution. So I thought maybe there was a binding problem. And there was! One of my client was using Chinese domain name, but the binding was using Puny code, and IIS7.5/IIS7 don’t support Puny code, you should just input Chinese characters instead. So I did, and it worked!
Ok, the mail server part is solved, now I must handle the mail sending issue. At first I had no idea where to start. Then I decided to log SMTP activity, and I found those:
“SMTPD” 4244 38 “2010-08-14 17:45:49.968” “127.0.0.1” “SENT: 220 shawnidc.com ESMTP”
“SMTPD” 5468 38 “2010-08-14 17:45:49.984” “127.0.0.1” “RECEIVED: HELO ShawnIDC”
“SMTPD” 5468 38 “2010-08-14 17:45:49.984” “127.0.0.1” “SENT: 250 Hello.”
“SMTPD” 4244 38 “2010-08-14 17:45:49.984” “127.0.0.1” “RECEIVED: MAIL FROM:<[email protected]>”
“SMTPD” 4244 38 “2010-08-14 17:45:49.984” “127.0.0.1” “SENT: 250 OK”
“SMTPD” 4244 38 “2010-08-14 17:45:49.984” “127.0.0.1” “RECEIVED: RCPT TO:<[email protected]>”
“SMTPD” 4244 38 “2010-08-14 17:45:49.984” “127.0.0.1” “SENT: 550 Unknown user”
“SMTPD” 4244 38 “2010-08-14 17:45:50.000” “127.0.0.1” “RECEIVED: QUIT”
“SMTPD” 4244 38 “2010-08-14 17:45:50.000” “127.0.0.1” “SENT: 221 goodbye”
Ok, finally I figured out what was going on, the mail [email protected] is using his own mail server, ie. the MX record didn’t point to my server, but hMailServer still takes yyy.com as a local mail system.
So here is the solution. Check the log to find out which mail is not working and then delete the mail server record in hMailServer.
Finally, everything is working now. Hope my article could help you a bit! Please comment on this if you still have any questions.