Setting up internal catch-all address

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

Setting up internal catch-all address

Jivan Pal
Hello,

All of my mailboxes are virtual, e.g. `[hidden email]` and `[hidden email]`.
I would like to set up a catch-all virtual mailbox `[hidden email]`
such that mail sent to any other address `*@example.com` gets sent to
`[hidden email]`.

Here is an excerpt of my config:

> == /etc/postfix/main.cf ==
> mydestination =
> virtual_mailbox_domains = example.com
> virtual_mailbox_maps    = hash:/etc/postfix/virtual_mailboxes
> virtual_alias_maps      = hash:/etc/postfix/virtual_aliases
> virtual_mailbox_base    = /var/mail/virtual

> == /etc/postfix/virtual_mailboxes ==
> [hidden email]   example.com/alice/
> [hidden email]     example.com/bob/

> == /etc/postfix/virtual_aliases ==
> @example.com            [hidden email]
> [hidden email]       [hidden email]       ##
> [hidden email]         [hidden email]         ##
> [hidden email]  [hidden email]


Notably, the lines marked `##` are *required* for mail delivery to work as
expected. If they are omitted, then *all* mail for example.com ends up in the
`[hidden email]` mailbox --- Alice and Bob can't see their mail!
Based on [1], my understanding is that the `@example.com` syntax was designed
for true mail-forwarding domains, i.e. those where no mailboxes exist, so all
mail must be forwarded to one or more other domains. However, my question is
whether simpler syntax/configuration exists for partial forwarding such as the
internal catch-all behaviour I'm after (or, indeed, just a simpler config for my
particular use case) --- is there another way to set this up so that, in future,
as more mailboxes are added to the domain, there isn't a need to include a
"redundant" alias like `##` for every mailbox besides the catch-all one?

Thanks,
Jivan

[1] Mail forwarding domains:
  http://www.postfix.org/VIRTUAL_README.html#forwarding
Reply | Threaded
Open this post in threaded view
|

Re: Setting up internal catch-all address

Jivan Pal
Problem solved! Firstly, a correction to my original post. The file
`/etc/postfix/virtual_mailboxes` should have had an aditional line, as follows:

> == /etc/postfix/virtual_mailboxes ==
> [hidden email]     example.com/alice/
> [hidden email]       example.com/bob/
> [hidden email]  example.com/catchall/   # Previously missing line

Now, the problem was solved by specifying the catch-all address not as an alias
in `/etc/postfix/virtual_aliases`, but instead as a mailbox in
`/etc/postfix/virtual_mailboxes`, as follows:

> == /etc/postfix/virtual_mailboxes ==
> [hidden email]     example.com/alice/
> [hidden email]       example.com/bob/
> # Catch-all mailbox belongs to user `[hidden email]`
> @example.com          example.com/catchall/   # Adjusted this line

> == /etc/postfix/virtual_aliases ==
> [hidden email]  [hidden email]

That is, the superfluous aliases `[hidden email] [hidden email]` and
`[hidden email] [hidden email]` no longer need to be specified, and the
mailbox resides at `/var/mail/virtual/example.com/catchall`, which I require in
order for my POP3/IMAP server (Dovecot) to fetch a user's mail based on which
username they log in with. Thus, if a user logs in as `[hidden email]`,
they can now see mail that has landed in the catch-all mailbox.

-- Jivan
Reply | Threaded
Open this post in threaded view
|

Re: Setting up internal catch-all address

Abhijith Sethuraj
In reply to this post by Jivan Pal
Have you tried reordering your config so that individual stuff gets picked up first and then if nothing succeeds use the catch all? I believe this is just a logic flaw inside your config.

On Fri, Mar 6, 2020, 17:24 Jivan Pal <[hidden email]> wrote:
Hello,

All of my mailboxes are virtual, e.g. `[hidden email]` and `[hidden email]`.
I would like to set up a catch-all virtual mailbox `[hidden email]`
such that mail sent to any other address `*@example.com` gets sent to
`[hidden email]`.

Here is an excerpt of my config:

> == /etc/postfix/main.cf ==
> mydestination =
> virtual_mailbox_domains = example.com
> virtual_mailbox_maps    = hash:/etc/postfix/virtual_mailboxes
> virtual_alias_maps      = hash:/etc/postfix/virtual_aliases
> virtual_mailbox_base    = /var/mail/virtual

> == /etc/postfix/virtual_mailboxes ==
> [hidden email]   example.com/alice/
> [hidden email]     example.com/bob/

> == /etc/postfix/virtual_aliases ==
> @example.com            [hidden email]
> [hidden email]       [hidden email]       ##
> [hidden email]         [hidden email]         ##
> [hidden email]  [hidden email]


Notably, the lines marked `##` are *required* for mail delivery to work as
expected. If they are omitted, then *all* mail for example.com ends up in the
`[hidden email]` mailbox --- Alice and Bob can't see their mail!
Based on [1], my understanding is that the `@example.com` syntax was designed
for true mail-forwarding domains, i.e. those where no mailboxes exist, so all
mail must be forwarded to one or more other domains. However, my question is
whether simpler syntax/configuration exists for partial forwarding such as the
internal catch-all behaviour I'm after (or, indeed, just a simpler config for my
particular use case) --- is there another way to set this up so that, in future,
as more mailboxes are added to the domain, there isn't a need to include a
"redundant" alias like `##` for every mailbox besides the catch-all one?

Thanks,
Jivan

[1] Mail forwarding domains:
  http://www.postfix.org/VIRTUAL_README.html#forwarding
Reply | Threaded
Open this post in threaded view
|

Re: Setting up internal catch-all address

Abhijith Sethuraj
Oh nevermind. Just saw there's a newer update on this thread.

On Sun, Mar 8, 2020, 13:31 Abhijith Sethuraj <[hidden email]> wrote:
Have you tried reordering your config so that individual stuff gets picked up first and then if nothing succeeds use the catch all? I believe this is just a logic flaw inside your config.

On Fri, Mar 6, 2020, 17:24 Jivan Pal <[hidden email]> wrote:
Hello,

All of my mailboxes are virtual, e.g. `[hidden email]` and `[hidden email]`.
I would like to set up a catch-all virtual mailbox `[hidden email]`
such that mail sent to any other address `*@example.com` gets sent to
`[hidden email]`.

Here is an excerpt of my config:

> == /etc/postfix/main.cf ==
> mydestination =
> virtual_mailbox_domains = example.com
> virtual_mailbox_maps    = hash:/etc/postfix/virtual_mailboxes
> virtual_alias_maps      = hash:/etc/postfix/virtual_aliases
> virtual_mailbox_base    = /var/mail/virtual

> == /etc/postfix/virtual_mailboxes ==
> [hidden email]   example.com/alice/
> [hidden email]     example.com/bob/

> == /etc/postfix/virtual_aliases ==
> @example.com            [hidden email]
> [hidden email]       [hidden email]       ##
> [hidden email]         [hidden email]         ##
> [hidden email]  [hidden email]


Notably, the lines marked `##` are *required* for mail delivery to work as
expected. If they are omitted, then *all* mail for example.com ends up in the
`[hidden email]` mailbox --- Alice and Bob can't see their mail!
Based on [1], my understanding is that the `@example.com` syntax was designed
for true mail-forwarding domains, i.e. those where no mailboxes exist, so all
mail must be forwarded to one or more other domains. However, my question is
whether simpler syntax/configuration exists for partial forwarding such as the
internal catch-all behaviour I'm after (or, indeed, just a simpler config for my
particular use case) --- is there another way to set this up so that, in future,
as more mailboxes are added to the domain, there isn't a need to include a
"redundant" alias like `##` for every mailbox besides the catch-all one?

Thanks,
Jivan

[1] Mail forwarding domains:
  http://www.postfix.org/VIRTUAL_README.html#forwarding