On 19/11/17 05:04 PM, Viktor Dukhovni wrote:
On Nov 19, 2017, at 11:36 AM, Jack Bates <vgn...@nottheoilrig.com> wrote:
Is there a feature I can use to rewrite the To: header, of "virtual alias 
domain" mail, with the result of the following lookup, *after* smtpd_milters are 
applied?

SELECT 'b...@example.com' FROM my_table WHERE sender = '%s'

Or do I need to use a milter of my own for this?

Header rewriting in cleanup(8) happens before headers are passed to milters.
The header address rewriting mechanism that happens after milters is done
in smtp(8) via smtp_generic_maps.  So if the mail in question will be
forwarded-on via SMTP, you can configure your rewriting logic via
smtp_generic_maps, but keep in mind that with smtp_generic_maps:

   * You can't make the rewriting of recipient addresses depend on the
     sender.  The only input to each lookup is the address that may be
     replaced.

   * All addresses are rewritten, envelope and header, sender and recipient,
     not just header recipient addresses.

Your example of:

     SELECT 'b...@example.com' FROM my_table WHERE sender = '%s'

will rewrite any address listed in the table to <b...@example.com>
whether it is a sender or recipient address, a header address or
an envelope address.

My virtual alias domain mail isn't forwarded on via SMTP (it's delivered to a Maildir). Thank you nonetheless for your suggestion and explanation! I'm now confident that I'll need to use a milter.

Reply via email to