How do I Ignore local DNS and route email to internet

I have a dedicated server running Linux (CentOS)
I have two domains on the server example1.com and example2.com

example1.com has the website hosted on the server but it uses a different server for its email.  So the MX record for example1.com points to another commercial server (demon internet) who handle the email then forward it to the customers exchange server.

However the second domain example2.com needs to send emails to example1.com but these do not arrive.  After some head scratching I have come to the conclusion that the dedicated server is checking to see if example1.com is local , deciding it is because the website is hosted on the server, it is then trying to deliver the email to the dedicated server.  This fails becasue the dedicated server isn't storing the email for example1.com

Is there a way I can tell the dedicated server that when it has email for example1.com from example2.com to send the mail on to the internet where it will then pick up the correct MX record and forward it to demons mail and onto the customer.
Thanks
Nacho_ManAsked:
Who is Participating?
 
vipul999Commented:
web server2 is sending mail to webserver1 instead of sending it to email server for domain1

webserver 2 should use an smtp relay outside of itself ideally. Or sendmail should be configured right. It doesnt seem to be trying to get the mx records for the domain.

you could try using XpertMailer script which allows you to send mail via smtp also.

Also found this at php mail() functions webpage if it relates:

You must take extra care if the machine that is sending the mail also operates mail forwarding for your domain and you are sending mail to a user at that domain.  In this situation, it is common for the MTA to avoid doing a "proper" MX look-up because it "knows" that there is a local list of mail-forwarding rules. This saves resources, and normally shouldnt be a problem, of course.

HOWEVER, if you deliberately alter your MX record to point to a mail server hosted elsewhere and, e.g. update your mail forwarding rules at that location,  AND the server that sends your PHP-generated mail "decides" that it will save resources by not checking the MX record THEN it will use your old set of forwarding rules because it is ignoring your MX record.
0
 
hemmiCommented:
How does "domain example2.com" send emails example1.com? Do you have a nameserver running on the server?

0
 
Nacho_ManAuthor Commented:
No the server does not run it's own nameserver, the hosting company has nameservers which we use.  
0
On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

 
hemmiCommented:
Still: how is the mail from "domain example2.com" being sent to example1.com? Is it a web php form, a remote user using a mail gateway, some local process ,..., etc.? There are a million ways of emitting mail from "domain example2.com" which seem to be sent to the wrong (namely example1 webserver) server.
0
 
Nacho_ManAuthor Commented:
Ok

The email is generated via php script using the "mail" command as an order confirmation.  One is sent to the customer and one to the people handling the orders. Both emails are generated and sent and customers get their copy without a problem.  

So I am assuming it is using sendmail.

Is that any help?
0
 
hemmiCommented:
What's in the mail log (ususally under /var/log), just after you've unsuccessfully sent an email through the php form?
0
 
shauncroucherCommented:
is there a mx record internally that is pointing to the web server for example1.com. it seems to me if you can make sure the mx record in dns is set to outside internet host, the webserver in question will then route to right place.

what dns server is the web server with form using?

shaun
0
 
Nacho_ManAuthor Commented:
The final quote there pointed me in the right direction ... there is a etc\localdomains file on the server which if edited to remove domain with remote mail server and added to remotedomains file email for that domain is not rooted locally.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.