PHP sendmail - emails never leave the server

yellowbelly

Registered
Oct 2, 2013
1
0
1
cPanel Access Level
Root Administrator
Hello,

I am transferring some websites to a new VPS running WHM/cPanel on CentOS (previously used Plesk).

One of my clients has a website hosted on my VPS, and their email hosted elsewhere.

On this website I am trying to send emails using a PHP script i.e:

PHP:
mail($to, $subject, $body, $headers, $ffrom);
This worked on the old server. However emails are not leaving the server.

When I look within WHM at Home » Email » Mail Delivery Reports the emails are shown as accepted. When I look at the Delivery Event Details for the email it shows the following:

Code:
Event:			success
User:			this_account_user
Domain:			this-website-domain.co.uk
Sender:			[email protected]
Sent Time:		Sep 23, 2013 2:16:14 PM
Sender Host:		localhost
Sender IP:		127.0.0.1
Authentication:		localuser
Spam Score: 
Recipient:		[email protected]
Delivered To:		[email protected]
Delivery User:		my_user
Delivery Domain:	my-domain.co.uk
Router:			localuser
Transport:		local_delivery
Out Time:		Sep 23, 2013 2:16:14 PM
ID:			1VO600-00022G-O4
Delivery Host:		localhost
Delivery IP:		127.0.0.1
Size:			698 bytes
Result:			Message accepted
As you can see the 'Recipient' and 'Delivered To' addresses are different and not what I want. It looks like whatever I try to do these emails are actually being sent to the root user ([email protected]).

This is the corresponding entry in the /var/log/exim_mainlog

Code:
2013-09-23 13:29:28 cwd=/home/this_account_user/public_html 3 args: /usr/sbin/sendmail -t -i
2013-09-23 13:29:28 1VO5Ga-0001np-RN <= [email protected] U=this_account_user P=local S=658 T="Brochure Request" for [email protected]
2013-09-23 13:29:28 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1VO5Ga-0001np-RN
2013-09-23 13:29:29 1VO5Ga-0001np-RN => my_user <[email protected]> R=localuser T=local_delivery
2013-09-23 13:29:29 1VO5Ga-0001np-RN Completed
I have several questions:
1) Where does the 'Delivered To' address actually come from? Because the address that is used is not provided by me as far as I am aware.
2) Even when the 'Delivered To' address is a valid email address and everything looks OK in the exim log, it still doesnt get delivered even though it shows as success/completed.

Any help with this is much appreciated.
Thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Please browse to:

"WHM Home » DNS Functions » Edit DNS Zone"

Select the domain name, and click on "Edit". Scroll down to the "Email Routing" section and ensure it's configured to:

"Remote Mail Exchanger"

This will ensure email is routed to the remote mail server where the email accounts are hosted at.

Thank you.