[Rspamd-Users] Rspamd, Postfix Milter, Alias Rewriting

Jesse Norell jesse at kci.net
Thu May 27 15:53:26 UTC 2021


On Thu, 2021-05-27 at 13:59 +0200, Florian D via Users wrote:
> Hi,
> 
> I've got a question about using rspamd right with virtual aliases.
> 
> I have a postfix+rspamd setup where rspamd is set as the milter of
> postfix.
> 
> I activated bayes per user in rspamd.
> 
> I now discovered, that it seems to either ignore "Delivered-To"-
> header 
> or does not get the information by postfix about it, since it only
> uses 
> the bayes data of the alias entries, not of the "final" mailbox
> entries.

Rspamd is running as a milter, at which time the message has not been
delivered, and as such there will be no Delivered-To header yet.
 (Well, none added by your system; a message could have arrived with
one already set.)



> My postfix email/alias setup:
> ---
> # first user:
> aliasB1 at domainB.com -> mailbox at domainA.com
> aliasB2 at domainB.com
> ... etc
> 
> # other user:
> aliasC1 at domainC.com -> mailbox at domainD.com
> ... etc
> ---
> 
> rspamd now looks for user bayes only for the aliases alias*@... ,
> and 
> not the "final destination" mailbox at ...


Correct, that is both my understanding of how it is intended to work,
and aligns with my testing/observations.



> my postfix milter config:
> ---
> smtpd_milters = inet:localhost:11332
> non_smtpd_milters = inet:localhost:11332
> milter_protocol = 6
> milter_mail_macros =  i {mail_addr} {client_addr} {client_name} 
> {auth_authen}
> milter_default_action = accept
> 
> # content: aliasB1 at domainB.com mailbox at domainA.com, ...
> virtual_alias_maps = hash:/etc/postfix/virtual-aliases.hash
> # content: domainA.com, domainB.com, ...
> virtual_mailbox_domains = hash:/etc/postfix/virtual-domains.hash
> # content: mailbox at domainB.com domainB.com/mailbox/, ...
> virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox.hash
> ---
> 
> my rspamd bayes config (override.d/classifier-bayes.conf):
> ---
> users_enabled = true;
> ---
> 
> I thought the milter runs after rewriting the addresses? Is there a
> way 
> to see it in the log files?


No, per http://www.postfix.org/MILTER_README.html the milter runs in
smtpd(8) or in cleanup(8) depending on the source of the message;
address mapping happens in the cleanup(8), so at the time rspamd sees a
message from smtp, no address mapping has been performed.


> What do I need to change or enable (either postfix or rspamd?) to
> see 
> better whats wrong or fix this?

I don't believe there's anything wrong or needing fixed per se, just do
any manual training as the alias rather than as the mailbox, or both, I
suppose.  I don't know if there's any way (eg. lua function) you could
either change what keys were queried for an alias, or to override the
recipient address in rspamd (I don't see anything obvious, but don't
know the internals that well), that would probably require a feature
request (to specify a map of addresses, maybe?).  Likewise changing
postfix's behavior to perform address mapping would also likely require
a feature request.


-- 
Jesse Norell




More information about the Users mailing list