Route all *BUT* dedicated IP addresses through smarthost

justjaph

Member
Oct 17, 2013
10
0
1
cPanel Access Level
Root Administrator
Hi all.

I need to route all outbound email through a smart host but not the email that comes from the clients/resellers that have dedicate IP addresses.

Using a suggestion found somewhere else, this is what I got:

Scenario: Server has 3 IP addresses - 192.168.1.1 is the shared one, 192.168.1.2 and 192.168.1.3 are dedicated to clients. Relay is myrelay.domain.dom.

(note: "fictional" IP addresses. The server has -of course- public and routeable IP addresses).

First approach: All from 192.168.1.1 and from "nothing" (local generated emails by scripts, for instance):

Section: TRANSPORTSTART

remote_smtp_smart_regular:
driver = smtp
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}

Section: ROUTERSTART

smarthost_regular:
driver = manualroute
domains = !+local_domains
transport = remote_smtp_smart_regular
route_list = $domain myrelay.domain.dom
condition = ${if or { {match_ip{$received_ip_address}{192.168.1.1}} {eq{$received_ip_address}{}} }}

Second approach: everything but dedicated IP addresses:

Section: TRANSPORTSTART

remote_smtp_smart_regular:
driver = smtp
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}

Section: ROUTERSTART

smarthost_regular:
driver = manualroute
domains = !+local_domains
transport = remote_smtp_smart_regular
route_list = $domain myrelay.domain.dom
condition = ${if !match_ip{$received_ip_address}{192.168.1.2,192.168.1.3}}

Both attempts failed miserably, as email coming from the dedicated IP addresses is being routed to the relay ...

Can anyone spot what am I doing wrong here ?

Regards,

./J