Re: [exim] Email sent out depending on port received

Top Page
Delete this message
Reply to this message
Author: Phil Pennock
Date:  
To: Jeroen van Aart
CC: exim-users
Subject: Re: [exim] Email sent out depending on port received
On 2008-04-21 at 16:43 -0700, Jeroen van Aart wrote:
> I would like to know how to configure exim to send out email to the
> internet, which it receives on a specific port. For example if it
> receives email on 127.0.0.1:24 it should send it out. In all other
> cases, say submission on externalIP:587 email will be sent to a smarthost.


There's more than one way to do it.

Option 1a: Embed the permissions policy directly in the Router which
sends email out (whether a smarthost or a dnslookup Router)

Option 1b: Embed the policy in an ACL and check the policy in the
Router, via an intermediate variable such as $acl_c_permitoutbound.

Option 2: change the RCPT ACL so that remote delivery is only permitted
if the policy is matched; that ties the logic directly in to the point
where this decision is made.

The variable you want is called $received_port (or $interface_port, its
old name; it was renamed for clarity, the old name still works).

The idea is that the "verify = recipient" check will fail if there is no
router that handles the email.

On the Router, one of:
condition = ${if =={$received_port}{24}}
condition = ${if =={$acl_c_permitoutbound}{1}}

If you set the ACL variable in the connect ACL, it'll be available for
all messages received in that connection, for the lifetime of the
message. Alternatively, you can use an acl_m_<whatever> variable and
set it in your RCPT ACL.

If you want to provide a "relay not permitted" message, then instead of
blocking the Router, you can just update the local/relay check in the
RCPT ACL, adding the third line here:

  require message = relay not permitted
          domains = +local_domains : +relay_to_domains
      condition = ${if =={$received_port}{24}}


Or you could do both checks, as a "belt and braces" approach.

If you want to check that the mail was received from this machine, on
port 24, then:

 condition = ${if and{{=={$received_port}{24}}\
     {match_ip{$received_ip_address}{@[]}}}}


ie: the port must be 24 and the IP address it was received from must be
one of the IP addresses which Exim considers local (by default, the IP
addresses of this machine).

Regards,
-Phil