Warning: mail() SMTP server response: Need Rcpt command
I recently moved my website to a new host and I started getting this error when I would try to submit a form:
Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command.
The email would send to the recipient, but the receipt would not send to the sender. Error said it was on line 51. I highlighted line 51 in red. Here is a part of the code:
check that $sender = $_POST['emailedBy'] is actually getting set, the error itself means that you don't have a mail recipient ($sender) , check that is not empty.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
I feel like it is getting set. The user is inputing their email into a text box that has name = "emailedBy". How would I check further into this issue? Thanks for your help!
Don't forget that headers should be separated by \r\n as well. Its possible that its misinterpreting the from header and considering everything as a part of the from.
Fou-Lu - I have the headers seperated by \n. Is that fine or would it solve the issue by seperating them by using \r\n? I have never had an issue before just using \n.
I can't say it will solve the issue. But RFC specifies that headers are separated by \r\n, not by \n which separates content.
That's the very first thing I'd check. Mail() is somewhat tricky since it has quirks depending on the OS in use.
Thanks. I tried seperating the $headers by \r\n, but the issue is still there. I am not sure why it is not able to pull the $sender email and then send the email. The first mail() option is working, but the second mail() option to the $sender is not.
Is it not pulling the sender out of the post?
Check and see what the value of $sender is. If its a valid email, this is a host configuration that's blocking it.
No luck. I tried to echo $sender, but when I submitted the form it did not output an email address. It just gave me the same error that I started with. What could my next step be? Thanks
The problem is most likely on the form side. Like I said, print out the post variables, see if it matches what you think you should get. If not, then you know where your problem is.