switala

Registered
Dec 20, 2003
1
0
151
How do I setup relays for a domain in CPanel. Just like I always do in the /etc/mail/mailertable in Sendmail.

I have a domain's email that I have to relay to a private IPAddress on the internal network

domain.com smtp:[192.168.0.9]

Thank you
 

projectandrew

Well-Known Member
Aug 27, 2003
184
0
166
United Kingdom
Just cracked it - spent the afternoon trawling around google, and finally pieced together this solution - a quick how-to:

1. Type the following when logged in via SSH

Code:
touch /etc/staticroutes
pico /etc/staticroutes
2. Add entries in the format:

Code:
domainname.com: target.mail.server
3. Press CTRL-O to save the file, then CTRL-X to exit the pico editor.

4. In WHM, under 'Service Configuration' choose 'Exim Configuration Editor', then click 'Switch to Advanced Editor'.

5. Scroll down to the 'ROUTERS CONFIGURATION' section, and in the white space underneath, add the following:

Code:
static_route:
  driver = manualroute
  transport = remote_smtp
  route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
6. Scroll to the bottom of the page and click 'Save' - Exim will automatically restart.

Well chuffed, since I can now route mail for some of my customers domains, once they've been scanned for viruses and spam on my cpanel servers (I use the RVSKin virus/spam solution/howto), to their Exchange servers...
 

NetBlaster

Member
Jun 12, 2004
23
0
151
What happens if the remote mail server is down? Does the mail accumulate on the source server until the remote server becomes available?

Ron...
 

Acieke

Member
Nov 13, 2004
13
0
151
projectandrew said:
Just cracked it - spent the afternoon trawling around google, and finally pieced together this solution - a quick how-to:

1. Type the following when logged in via SSH

Code:
touch /etc/staticroutes
pico /etc/staticroutes
etc etc

I also posted a post on this, and I was told to search for smart routers. It seems to work just fine, until I specify the port number; then I get:
2005-12-14 22:25:16 1Eme7f-0004EB-TZ == xxx@xxx R=static_route T=remote_smtp defer (22): Invalid argument
Anyways, I have to forward mail to another port too; any possibilities on that ?

Thanks
 

NetBlaster

Member
Jun 12, 2004
23
0
151
I'm sure I got this from chirpy but this is what I'm doing and it works perfect.


ROUTERS
Code:
smart_route:
  driver = manualroute
  route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
  transport = remote_smtp_smart

TRANSPORTS
Code:
remote_smtp_smart:
  driver = smtp
  port = 6625
  hosts = ${lookup{$domain}lsearch{/etc/staticroutes}}
  hosts_override
 

Acieke

Member
Nov 13, 2004
13
0
151
Okay, thanks for that, I added the second code block, changing 6625 to the port of the destination mail server..
But now I get the following error for all queued and new sent messages:
2005-12-15 14:30:44 1Em8pc-0001lO-6H == xxx@xxx R=static_route T=remote_smtp defer (-53): retry time not reached for any host


Any ideas?
Thanks
Frederic
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
The error would suggest that exim is not able to connect from your server to the remote IP on that port. Have you tried logging into the cPanel server and using:

telnet ip-of-server 6625

Make sure that you get the SMTP banner. type quit to end the session.

If that works, then perhaps you don't have the correct details in your /etc/staticroutes file?
 

forlinuxsupport

Well-Known Member
PartnerNOC
Dec 22, 2004
386
0
166
cPanel Access Level
Root Administrator
Sorry to open an old post.

Will the steps below get cpanel server to accept mail and scan it for spam and then relay it on ?

ROUTERS
Code:

Code:
smart_route: 
             driver = manualroute
             route_data = ${lookup{$domain}lsearch{/etc/staticroutes}} 
             transport = remote_smtp_smart


TRANSPORTS
Code:

Code:
remote_smtp_smart: 
                driver = smtp 
                port = 6625 
                hosts = ${lookup{$domain}lsearch{/etc/staticroutes}} 
                hosts_override
Ive got this in routes and it DOESNT scan the email it just relays it on fine.

ROUTERS
Code:
static_route:
  driver = manualroute
  transport = remote_smtp
  route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
 

forlinuxsupport

Well-Known Member
PartnerNOC
Dec 22, 2004
386
0
166
cPanel Access Level
Root Administrator
I got this direct from cpanel to make the relaying server also scan the emails.

This can be done simply by adding the aforementioned condition to the static_route router, which is presently defined in your exim configuration:

static_route:
driver = manualroute
condition = "${perl{checkspam}}"
transport = remote_smtp
route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
 

dinfiesta

Well-Known Member
May 2, 2005
58
0
156
projectandrew said:
Just cracked it - spent the afternoon trawling around google, and finally pieced together this solution - a quick how-to:

1. Type the following when logged in via SSH

Code:
touch /etc/staticroutes
pico /etc/staticroutes
2. Add entries in the format:

Code:
domainname.com: target.mail.server
3. Press CTRL-O to save the file, then CTRL-X to exit the pico editor.

4. In WHM, under 'Service Configuration' choose 'Exim Configuration Editor', then click 'Switch to Advanced Editor'.

5. Scroll down to the 'ROUTERS CONFIGURATION' section, and in the white space underneath, add the following:

Code:
static_route:
  driver = manualroute
  transport = remote_smtp
  route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
6. Scroll to the bottom of the page and click 'Save' - Exim will automatically restart.

Well chuffed, since I can now route mail for some of my customers domains, once they've been scanned for viruses and spam on my cpanel servers (I use the RVSKin virus/spam solution/howto), to their Exchange servers...
How do I specify all domains? (talking about point number 2)

Thanks.
 

forlinuxsupport

Well-Known Member
PartnerNOC
Dec 22, 2004
386
0
166
cPanel Access Level
Root Administrator
Hi

Just like this.


forlinux.co.uk: 200.0.0.56
forlinuxhosting.co.uk: 200.0.0.57

Just list all of them on right and ip on left :) bit of command line scripting :)


Left = domain hosted on the server that you want to do the forwarding on.

IP / Domain on right = address of server you want to relay to (e.g. exchnage server)

Regards
Andy
 

WestBend

Well-Known Member
Oct 12, 2003
173
0
166
Just an addendum to this thread.

You MAY need to alter your exim_outgoing.conf with the same router info. Maybe thats a given but everyone seems to only mention exim.conf and it took me days to realize it needed to go into the outgoing.conf
 
Last edited:

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
So long as you correctly put add the router information to the exim configuration editor, then /scripts/mailscannerupdate will automatically copy the static router code into both exim.conf and exim_outgoing.conf - you should never need to edit exim_outgoing.conf (or exim.conf for that matter).
 

WestBend

Well-Known Member
Oct 12, 2003
173
0
166
I hadn't updated my prior post yet. I was using a set of instructions from the web which had me directly altering the exim.conf however i did not know that editing it via WHM actually updated multiple conf files i.e. exim.conf and exim_outgoing.conf. When i followed the instructions exactly and went through WHM it was very simply :).