On Mon, Aug 31, 2015 at 06:18:02PM +0200, Donovan Watteau wrote:
> 2015-08-29 15:00 GMT+02:00 Gilles Chehade <[email protected]>:
> > On Thu, Aug 27, 2015 at 05:27:29PM +0200, Donovan Watteau wrote:
> >> Hi,
> >>
> >> I'm configuring OpenSMTPD 5.7.1p1 on Debian 7.8.
> >>
> >> I'm looking for something like this:
> >>
> >>   # Use this when "From: [email protected]" is set:
> >>   accept for any relay via $myrelay
> >>   # Keep default relay in all other cases:
> >>   accept for any relay
> >>
> >> So, having read smtpd.conf(5), I thought "sender" would be what I'm 
> >> looking for:
> >>
> >>   accept sender "[email protected]" for any relay via $myrelay
> >>   accept for any relay
> >>
> >> Unfortunately, my email is never relayed through $myrelay, although
> >> "From: [email protected]" is set.  Am I misunderstanding what "sender" is
> >> about?
> >>
> >
> > It uses the SMTP-level sender, not the DATA-level sender.
> 
> OK, thanks, but I still don't know if there's a way to achieve
> something like this
> 
>    # Use this when "From: [email protected]" (or any other header...) is set:
>    accept for any relay via $myrelay
>    # Keep default relay in all other cases:
>    accept for any relay
> 
> with OpenSMTPD.  Is it possible? impossible? impossible but there
> might be a way to work around this?
> 

Sorry, I'll explain more clearly.

The sender appears in two places:

- the protocol, where it is used in the MAIL FROM command;
- the DATA. where it is used in headers;

Both do not have to match, this is actually a feature of SMTP.

The decision to accept mail for delivery or relaying is based on the
protocol solely, it takes place before client event sends headers so
by the time a header has been received the route was already chosen.

A ruleset can therefore only match a protocol-level sender and it is
not possible to match a sender in headers. If a client uses the same
header for protocol and headers, it will work, otherwise it will not
and you can't do much about it.

Now what you want to do is still possible, but it requires more than
just a ruleset:

- you need to add tagged listeners:

  listen on [...] port $port1 tag ROUTE_A
  listen on [...] port $port2 tag ROUTE_B
  listen on all


- you need to add rules that match these tagged listeners:

  accept tagged ROUTE_A from local [...] relay via host1
  accept tagged ROUTE_B from local [...] relay via host2


- on your general listener you need to have a rule that passes the
  message to a script of yours:

  accept from any for domain [....] deliver to mda [...]


- then you need this script to parse headers, extract senders and
  resubmit the message to the listener that has the tag that
  matches the route you want to take.


This is the same approach as used with dkimproxy and the like.


-- 
Gilles Chehade

https://www.poolp.org                                          @poolpOrg

-- 
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]

Reply via email to