• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

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
0
Nacho_Man
Asked:
Nacho_Man
1 Solution
 
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
 
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
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
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
 
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
 
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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now