hosting domain with external mail server

drmuey

Member
Jun 10, 2003
17
0
151
Howdy,

We have a domain that we host the website for on Cpanel.

They have their own mail server at a different IP.

I've changed their MX record and if you do a host, dig, or nslookup you get the proper info back.

I also put an entry in /etc/hosts for it.

The problem is that if another domain on that same cpanel server sends mail to the domain with it's own mail server it gets delivered locally, bypassing /etc/hosts and dns!

Therefore the domain with their own mail server do not receive mail from other domains hosted on the same cpanel server since it gets deleiverd locally and not to their mail server.

Any ideas how to get exim to use /etc/hosts or dns?

Or other wise have it not delivered locally but to their mail server?

Thanks

Dan

cPanel.net Support Ticket Number:
 

dotlizard

Registered
May 19, 2003
2
0
151
same trouble here

We are having the same problem here, can't send email to our client, and also, the main account where all the unroutable messages go, will not forward off of the server.

Client will not consider using these mailservers.

cPanel.net Support Ticket Number:
 

drmuey

Member
Jun 10, 2003
17
0
151
This is what exim told me:
check the entry for
local_domains
in your exim.conf file

Mine is in /etc/exim.conf and local_domains actuall uses a text file:
/etc/localdomains
You just remove the domain from that file and it *should got to /etc/hosts and then on to dns.

This is what I'm testing as afix right now:

if yu can do host -t mx domain.com
and get the mx domain, say mail.domain.com then
host mail.domain.com
and get the proper ip address then removing it form the above file should make it sedn to the remoter mail server instead of locally.
Key word being should, but since I've done that today, no more messages have been sent locally, IE their inbox file hasn't gotten any bigger which it would before.

If you try thatand it works let em know!
Thanks

Dan Muey

cPanel.net Support Ticket Number:
 

drmuey

Member
Jun 10, 2003
17
0
151
All indications are that this is working now.
Basically it would be nice if Cpanel removed it for you when you change a domain's mx record/mx domain ip address to a remote mail server or give them the option to remove it from the local exim system and tell them they may want to do that when they mess with the mx records.

Hope that helps!

Dan Muey

cPanel.net Support Ticket Number:
 

pguy

Well-Known Member
Feb 21, 2003
73
0
156
You will need to remove the domain entry from /etc/userdomains and /etc/localdomains . However if you run /scripts/mailperm, it will add the entries back to /etc/localdomains.

So what you need to do in addition to removing it from /etc/localdomains is to add the domain name in /etc/remotedomains. Once you add it there, the scripts will not make any automatic changes.


Warm Regards

cPanel.net Support Ticket Number:
 

drmuey

Member
Jun 10, 2003
17
0
151
Excellent! Thanks a million! That is good to know.
Are the other two files you mentioned used by Exim like /etc/localdomains is?
I just don't want to mess up any of their cpanel stuff.

Thanks again I'm sure many people will find this usefull.

Dan Muey

cPanel.net Support Ticket Number:
 

pguy

Well-Known Member
Feb 21, 2003
73
0
156
Hello Dan,

I just did a similar setup for a client and found that Cpanel adds the domain name to /etc/remotedomains automatically. My experience previously was that it never used to.

I guess they finally updated it to work fine :D

However since some of you are still facing the issues, I am not really sure if its the case across all the servers.

I'll tell you what you need to do in a Step by Step way -

1) Use WHM to edit DNS and change the MX entries.
2) pico /etc/localdomains & remove the domain name
3) pico /etc/remotedomains & check if the domain you edited is there. If not, add it.

I mentioned in my previous message about /etc/userdomains , you can ignore that. It will get added right back during a cpanel update or by running of other certain scripts.

Regards,

cPanel.net Support Ticket Number:
 

decebal

Registered
Mar 19, 2002
3
0
301
excellent

thanks a million ... this works ... i was wondering what the remotedomains does.

:)

decebal

cPanel.net Support Ticket Number:
 

Drake

Well-Known Member
Nov 9, 2001
83
0
306
New Jersey
cPanel Access Level
DataCenter Provider
Why hasn't anyone mentioned changing the MX entry and the 'mail' subdomain in the DNS zone file to point at the external mail server? That way any incoming mail will go directly elsewhere as specified.

www.DuraServer.net
Web Hosting ~
Shared & Dedicated Servers ~
Networking ~ Linux
 
Last edited:

pguy

Well-Known Member
Feb 21, 2003
73
0
156
The server will first check if the domain exists locally. If that is the case, it will first try to deliver the email locally. This will happen if you have scripts/formmails etc installed on the domain.

Since they run on the server, they will directly deliver the email to the server first without looking outside.

cPanel.net Support Ticket Number:
 

spaceman

Well-Known Member
Mar 25, 2002
518
12
318
A small related note that might help others:

If your name servers are _not_ authoritative for the hosted domain (ie. your client manages their own DNS and mail servers), then consider 'Deleting the DNS zone file' for the domain as well via WHM. The risk of not doing this (and instead pointing MX records to their mail server) is that if your client changes their mail setup (name, ip), mail for them passing through your server (eg. from a web form) will be delivered to the wrong location and it can take a while before anyone notices. We've been caught out by this on a number of occasions.

Hope that helps someone :)

cPanel.net Support Ticket Number:
 

pavemen

Active Member
Oct 8, 2003
27
0
151
Sorry to bring this back from the dead, but I found a few new issues that this thread fixed.

I had a server restored and restored my backups. One of the accounts used everyone.net. It worked perfect prior to the OS restore. It worked after teh account restore.

Then I installed the MailScanner 1.5 from layer1. Wasnp;t working like I had hoped it would (had it on previous OS image without issue) so I used the uninstall.

After the uninstall, mail to the domain using everyone.net no longer was delivered as it failed internally. Apparently the mailscanner uninstall reverted all my /etc/*domains files and mail was no longer routed correctly.
 

iamclogger

Registered
Dec 9, 2004
1
0
151
If the remotehosts and localhosts files are not in the /etc folder what is the format of those files if I need to create them?

Can someone post an example of their file for me to reference?

Thanks
 

DavidR

Well-Known Member
Feb 25, 2003
177
0
166
I have a question along these lines. In the same situation, with a domain client wanting to use their outside servers for email, they give me an IP to forward MX to. Now, cPanel says you can't forward MX to an IP, only a domain name. So, would it be wise to edit the domain zone for their domain with me so that mail.domain.com goes to the ouside IP, then change MX records to forward to mail.domain.com? This has been confusing to me for some time. Thanks.
 

haze

Well-Known Member
Dec 21, 2001
1,540
3
318
VIA WHM edit the dns zone so that the mail.domain.com points to the IP And change it from cname to A record. Make sure the MX has the mail.domain.com bit. Then in SSH, ad the domain to the /etc/remotedomains file on a new line then run /scripts/mailperm and your done!
 

DavidR

Well-Known Member
Feb 25, 2003
177
0
166
Just to clarify, we are talking about files named "localdomains" and "remotedomains", not "localhosts" and "remotehosts", correct?

David