On 15 January 2017 at 08:51, Jan Ceuleers <jan.ceule...@computer.org> wrote:

> On 14/01/17 20:58, Richie Rich wrote:
> > Thanks for the quick response. Can you point me in a direction to
> > accomplish what I'm trying to do?
> > I'm totally new to postfix.
>
> I am by no means an expert, but I do hope that the following helps:
>
> http://www.postfix.org/postconf.5.html#smtp_generic_maps for the
> outgoing side and
> http://www.postfix.org/postconf.5.html#virtual_alias_maps for the
> incoming side.
>
>
Yes I agree that for incoming mails, virtual_alias_maps is the way to go, I
use 'virtual_alias_maps = pcre:/etc/postfix/virtual' and file 'virtual'
looks a bit like this (data obfuscated):

if /@streamingbats\.co(m|\.uk)$/
/^accounts@/ jenny...@gmail.com,jim9...@gmail.com
/^adam@/ adamdelane...@gmail.com
/^(input|sarah[-0-9a-z]*)@/ sarahcorriga...@gmail.com
/^(admin|administrator|dominic|MAILER-DAEMON|paypal|
payments|vps1|dl[12]|pbx|timedicer[12]?|hostmaster|postmaster|abuse)@/
myaddr...@gmail.com
endif
/@streamingbats\.co(m|\.uk)$/ root@localhost

I wrote a script to auto-configure postfix and intra alia this builds a
file 'filtered_names' from my 'virtual' file​. In one of my restrictions
lists I have line 'check_recipient_access pcre:/etc/postfix/filtered_names'.
This blocks emails to anyone@mydomains that isn't one of the names
explicitly remapped in my virtual file (except for authenticated senders)
and looks a bit like this:

if /@streamingbats\.co(m|\.uk)$/
/^accounts@/ OK
/^adam@/ OK
/^(input|sarah[-0-9a-z]*)@/ OK
/^(admin|administrator|dominic|MAILER-DAEMON|paypal|
payments|vps1|dl[12]|pbx|timedicer[12]?|hostmaster|postmaster|abuse)@/ OK
endif
/@streamingbats\.co(m|\.uk)$/ REJECT

For the outgoing mails, I originally used smtp_generic_maps but when I
started using opendkim I needed to switch to canonical (
http://www.postfix.org/canonical.5.html) - because the changes made by
canonical happen before milters (including opendkim), otherwise opendkim's
key line header is immediately broken by smtp_generic_maps' address
rewriting. So I have a line 'canonical_maps = hash:/etc/postfix/canonical'
and canonical file looks a bit like this:

<> d...@streamingbats.co.uk
root d...@streamingbats.co.uk
www-data d...@streamingbats.co.uk
postfix d...@streamingbats.co.uk
root@localhost d...@streamingbats.co.uk
root@dl1 d...@streamingbats.co.uk

​There may be simpler ways of achieving the same objectives (and I'd be
interested to hear of them), but these work for me.​

Reply via email to