Mail() Makes Me Want To Hide Under A Rock
I’m having a problem with PHP mail() function in my web hosting, but it worked several month ago. I guessed this is because they enabled sender address checking, as per an email they distributed some time ago, to make sure you do not use some bogus “from” address for spamming, phishing etc.
Ok, instead of using just plain mail($to, $subject, $body), I’ll change it to mail($to, $subject, $body, 'From: me@mydomain.tld'), adding “From” at the mail message header. Fair enough, no biggies. But when I tried it, it didn’t work!
It returned the error Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for receiver@someemailaddy.net in MyFile.php in line 666. Arrrghh. Stupid son of a mother… I then quickly tried sending mail from the webmail provided by the hosting control panel. It worked just fine!
Going into tension mode now. Okay, maybe I’ll go contact support, they’ll help. I went to the hosting website, and saw that their online chat support is online. Wow, 11.00 at night, and this is a local hosting. Can chat in Malay some more!
“Hi, mail() in PHP not working, error message: SMTP server response: 550 5.7.1 Unable to relay for blah blah blah”
The support person replied after several minutes, “Thanks for [some standard template message]”.
“mail() not working blah blah blah”, I repeat the problem.
“What’s ur domain?”
“ikhwanhayat.net”
“There’s nothing wrong. If not then thousands of user would have that problem. It’s ur code.”
What?! You are accusing me a newbie now! Demmit, I’m a professional developer you know! I write codes for a living okay! I’ve been known to be coding in my dream you know!! But of course I didn’t said it out loud, although I’m rather annoyed now.
“Do you set it to mail.ikhwanhayat.net”
“Yes, I did put the MX entry to mail.ikhwanhayat.net”, I explained, because some time ago I did change it to something else.
“U don’t need to change any MX records, that’s for DNS. It is not related. The problem is ur code.”
Hey, I know that, I’m just trying to imply that I’m not a newbie okay. I know MX records things okay! Not a n00b!
“Okay, I’ll check my codes again, maybe I left out something”
And I created a simple file, with just one line mail() function in it, upload it, and run it… And it worked fine!.
Wait… something fishy is going on. Oh no, is it because… aarrgh, demmit. I should just gauge my eyes out and feed it to the dogs. It just’ve dawned upon me that I did change my codes, FTP’d them to the server, but I tested the code in localhost.. -_-” Arrrgghhh.. this is so embarassing. My localhost can never do mail(), it’s Windows, I’ve never did gone through the hassle to setup the SMTP or whatever to make it work.
Okay… I’ll admit now that I’m a PHP n00b! Freakin’ st00pid n00b!!! I am so ashamed of myself, let me go hide under a rock.
Then I gave some lame excuse and said thanks to the support, and ran away as fast as I can. Heh, they got online chat support at night, my web hosting MesraHosting.net. (free link ad for you, I felt guilty that I disturbed you with my n00biness).
Trackbacks
Use this link to trackback from your own site.


hehehe, why dont you use php smtp class? mail is ok, but there’s not much you can do with it, php smtp class has more options, plus it has more security
I tried it, but got some error at that time. I know it can do more stuff, but mail() is sufficient for me right now. Do the least thing that work ;P
When you read paragraph 2, you’ll realize that i am dumb. Thats not the exact problem actually. Before this, i used mail($to, $subject, $body, ‘From: somebody@bogusdomain.tld‘) to send mail, for some reason (but not for spamming). The problem arise at the time i wanted to change it to mail($to, $subject, $body, ‘From: me@mydomain.tld‘).
Okay, i hope that makes me appear less dumb.
hahahhaha.. lawak lawak..
hehehee *gelak-tersipu-sipu*
<:-)
huhu … malu rasanya nak ngaku kau ni kawan aku. mx record konon :P
tapi aku pun pernah kena mcm ni jugak sebenarnya - http://www.k4ml.com/node/194
pun rasa malu kalau kau mengaku aku kawan ko.. ohohoho
:D