Reject email based on a key header?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Reject email based on a key header?

@lbutlr
Given an email address like [hidden email] is it possible to REJECT all email to that address that doesn't contain a header "X-foobar" (or maybe a header that that is "X-foobar: <notsosecretcode>")?

I know I could do this for all email addresses, but doing it for one would require some sort of simple milter in order to actually reject the email before accepting it, right?

(I may have asked this before, but if so turned out I went a different direction).

Similarly, given a email address of "[hidden email]" would it be possible to reject all emails to that address that did not contain an extension in the user name?

# using recipient_delimiter = +_

plus+plus = OK
plus+foo  = OK
Plus_bar  = OK
plus      = REJECT
plus+     = REJECT

--
'I'm not a thief, madam. But if I were, I would be the kind that
        steals fire from the gods.' 'We've already got fire.' 'There must
        be an upgrade by now.'

Reply | Threaded
Open this post in threaded view
|

Re: Reject email based on a key header?

Wietse Venema
@lbutlr:
> Given an email address like [hidden email] is it possible to =
> REJECT all email to that address that doesn't contain a header =
> "X-foobar" (or maybe a header that that is "X-foobar: =
> <notsosecretcode>")?

Postfix built-in support matches one line at a time, and the action
for that match cannot depend on earlier or later matches.

> I know I could do this for all email addresses, but doing it for one =
> would require some sort of simple milter in order to actually reject the =
> email before accepting it, right?

Any suitable non-builtin filter.

> Similarly, given a email address of "[hidden email]" would it be =
> possible to reject all emails to that address that did not contain an =
> extension in the user name?

> # using recipient_delimiter = +_
> plus+plus  OK
> plus+foo   OK
> Plus_bar   OK
> plus       REJECT

The above works. Postfix always tries to match the complete address
before stripping off the extension and matching the unextended name.

> plus+      REJECT

You don't need this, because Postfix will try the form without
address extension, and that form is already rejected.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Reject email based on a key header?

@lbutlr
On 07 Jan 2021, at 17:13, Wietse Venema <[hidden email]> wrote:
>> Similarly, given a email address of "[hidden email]" would it be =
>> possible to reject all emails to that address that did not contain an =
>> extension in the user name?

I should have said to "only allow emails that contain an address extension, any address extension, not a repopulated list."

I know what I was thinking!

>> # using recipient_delimiter = +_
>> plus+plus  OK
>> plus+foo   OK
>> Plus_bar   OK
>> plus       REJECT
>
> The above works. Postfix always tries to match the complete address
> before stripping off the extension and matching the unextended name.
>
>> plus+      REJECT
>
> You don't need this, because Postfix will try the form without
> address extension, and that form is already rejected.

Those were example of possible incoming usernames used in an email, not a list of allowed address+extension examples.

So, basically plus+<anything> or plus_<anything> is allowed, but plus@… is rejected.


--
🎼We all live in an Eldrich Horror's dream
                 an Eldrich Horror's dream
                 an Eldrich Horror's dream 🎵
Reply | Threaded
Open this post in threaded view
|

Re: Reject email based on a key header?

Wietse Venema
@lbutlr:
> I should have said to "only allow emails that contain an address =
> extension, any address extension, not a repopulated list."
>
> I know what I was thinking!=20
 
Use a regexp or pcre table.

/^foo[_+]?@example\.com$/ reject

        Wietse