Portal Home > Knowledgebase > Articles Database > PHP mail sending to the wrong server.


PHP mail sending to the wrong server.




Posted by Joels341, 03-27-2008, 01:07 PM
Hi, I have two servers, let's call them "webserver" and "email server". Both are Fedora Core 6, and both use Plesk (although the solution to my problem doesn't have to be Plesk specific). Or webserver used to handle or mail to, but we recently switched to a completely separate server to handle our mail. We updated the DNS and everything seemed to work just fine. But then we started to notice that we weren't receiving e-mails from PHP's mail() function. I searched the var/qmail/mailnames/xxxxxxx/Maildir and did not find the e-mails expected from mail(). I then searched the webserver for var/qmail/mailnames/xxxxxxx/Maildir/new for the e-mails, and lo and behold, they were there!!! Can someone please help me figure out how to make the php mail() function send to the correct server? Thank you for your time, Joel

Posted by Chris_M, 03-27-2008, 01:14 PM
Do a google search for qmail+smtproutes That should help you relay mail from the web server to your mail server.

Posted by Joels341, 03-27-2008, 02:35 PM
Thanks for you reply. I tried searching (the sites were very confusing), and it seems like I need to write something in this file var/qmail/control/smtproutes I did this :mail.mydomain.com I also tried :my_mail_server_ip But I am still not receiving my mail on the mail server... Any ideas?

Posted by Chris_M, 03-27-2008, 02:39 PM
Does your mail server allow for relaying from the web server? Did you restart qmail after making the changes to smtproutes file?

Posted by Joels341, 03-27-2008, 03:08 PM
I restarted qmail, still nothing. As for if it's allowed, I don't know. How can I tell? Maybe the command in my smtproutes is not right. if my domain for my site is mydomain.com, and the incoming mail server is mail.mydomain.com then all I need to do is put this in my smtproutes: mydomain.com:mail.mydomain.com Is this correct?

Posted by Joels341, 03-27-2008, 03:17 PM
The company we bought the server from says we need to configure PHP to use sendmail wrappers to use qmail. I don't know if this makes sense because the mail function IS already placing e-mails in the qmail directory, it's just going to the wrong server! They pasted to me the manual page for mail() from php.net. I am not sure if the completely understand what is going on or what I am trying to do..... Any ideas?

Posted by Chris_M, 03-27-2008, 03:37 PM
I use mail.mydomain.com and it works fine for me. But you will still need to figure out if the web server is allowed to relay mail via the mail server.

Posted by Joels341, 03-29-2008, 11:41 PM
I've tried doing some research, in Plesk, there is only an option that says "Relay: close or authorized SMTP". But there is nothing to really configure there. So I guess relay is allowed since closed is not selected. It seems like smtproutes is used by qmail-remote. Do you have sendmail = /var/qmail/bin/qmail-remote in your php.ini file? Maybe that is why you smtproutes file works and mine doesn't. I'm going to try it and I'll let you know.

Posted by Joels341, 03-31-2008, 10:45 AM
Didn't work, but when I went back to my original settings, I am no longer getting any mail at all.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read