On Fri, Jan 16, 2026 at 07:41:45AM -0800, Randy Bush via Postfix-users wrote:

> a bunch of vituals pass through my smtp inbounds.  one in particular,
> bogus.com (yes, bogus.com), attracts a lot of spam which i struggle to
> filter with rspamd.

Spam filtering can be difficult, use high quality RBLs, perhaps
postscreen can help, and if "rspamd" is in effective, test alternative
or multiple filters.

> bogus.com has only half a dozen legitimate local
> parts, i.e. foo in [email protected].  what is the simplest efficient way
> to drop all inbound for all but the half dozen legit local parts?

You have failed to mention whether this is, or is not a virtual alias
domain, and what addresses you have in mind (envelope or for some reason
header) when you say you want to "drop" mail for unexpected addresses.

On Fri, Jan 16, 2026 at 10:02:10AM -0800, Randy Bush via Postfix-users wrote:
> fwiw, my current hack is in `header_checks` a la
> 
>     /^To:.*[email protected]/            PASS
>     /^To:.*[email protected]/            PASS
>     /^To:.*[email protected]/            PASS
>     ...
>     /^To:.*@bogus.com/                DISCARD

That's a bad idea.  The regular expressions are far too imprecise,
and why are you trying to filter on header rather than envelope
addresses?  If any of the recipients ever receives legitimate mail from
a list, or otherwise as a forward or BCC, their specific address won't
be in the headers...

On Fri, Jan 16, 2026 at 04:46:55PM -0500, Bill Cole via Postfix-users wrote:

> A more elegant mechanism would be to do that in your virtual map. Use it to
> direct the valid addresses to their delivery points and discard the rest:

That's of course the correct thing to do, but a real virtual alias
domain already requires matching **envelope** addresses in the virtual
alias table, and I'd NEVER recomment use of regular expressions in that
context.

> virtual_alias_maps=pcre:/etc/postfix/virtual
> 
> virtual:
> 
>       /.*[email protected]/      [email protected]
>       /.*[email protected]/      [email protected]
>       /.*[email protected]/      [email protected]
>       /.*@bogus.com/          /dev/null

This has no effect on headers,, if (misguidedly) that's actually what
Randy is trying to filter.

The PCREs are poorly anchored, better REs would be:

    if /@bogus\.com$/
    /^foo@[^@]*$/       [email protected]
    /^bar@[^@]*$/       [email protected]
    /^feen@[^@]*$/      [email protected]
    fi

What is "/dev/null" supposed to mean there?  That's not valid syntax in
the virtual(5) alias table.  Mail to unknown virtual alias recipients is
automatically **rejected**, so there's no need for any discard logic.

And of course one should/would not use a regexp virtual(5) table:

  main.cf:
    indexed = ${default_database_type}:${config_directory}/
    virtual_alias_domains = bogus.com
    virtual_alias_maps = ${indexed}virtual

  virtual:
    [email protected]      [email protected]
    [email protected]      [email protected]
    [email protected]      [email protected]

-- 
    Viktor.  🇺🇦 Слава Україні!
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to