docker-mailserver / docker-mailserver

Production-ready fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.) running inside a container.
https://docker-mailserver.github.io/docker-mailserver/latest/
MIT License
14.85k stars 1.85k forks source link

feature request: Forward a copy of delivered mail to additional address(es) #3528

Open polarathene opened 1 year ago

polarathene commented 1 year ago

Context

Reference: https://github.com/orgs/docker-mailserver/discussions/3523#discussioncomment-6912407

Generally there is a misunderstanding with using setup alias add ... to forward mail to another address (eg: Gmail), avoiding local mail storage at DMS, but still wanting to send mail from that same alias as the sender address.

Sending mail requires an account via setup email add ..., but unless using SPOOF_PROTECTION=1 you do not need an account with matching address, and can choose any sender address to use.

We tried to resolve this confusion by preventing the command from allowing to create an account or alias when either an account or alias already exists using that address. Beyond this it's more of a documentation issue to better communicate the use-case and the solution (you only need one mail account in DMS to send from all addresses you've made aliases for).


A variant of this is not just forwarding mail to another MTA like Gmail, but also continuing to deliver the mail to Dovecot for storing.

DMS does not have a way to support this easily.

Description

This feature request exists to garner interest (via 👍 reactions).

If there is enough users needing it, the restriction on preventing creating an overlap between aliases and mail accounts could be relaxed (at least when the alias includes a recipient to itself, and that is also a mail account).

It would be better to identify a different way to support this if the feature does have enough demand (please share use-cases here). If other popular mail projects also configure their mail services to support this feature via aliases using a mail account with the same address as a recipient, this would help justify it.

# Mail account:
setup email add hello@example.com

# Alias to mail account using the same address (should deliver to the mail account, instead of skipping it):
setup alias add hello@example.com hello@example.com
# Additional address(es) to forward a copy to:
setup alias add hello@example.com external@not-example.com

Alternatives

Postfix has BCC settings that can provide control to still deliver mail while conditionally forwarding a copy to another address: https://github.com/orgs/docker-mailserver/discussions/3523#discussioncomment-6903403

It only seems to allow for a single BCC address to forward to per match. The user leverages an alias to workaround this as they've later revealed that they want to forward to multiple additional addresses.

Applicable Users

Seems niche, this FR is to gain additional insight if it's useful to officially implement support for.

Are you going to implement it?

No, and I understand that it is highly likely no one will implement it. Furthermore, I understand that this issue will likely become stale and will be closed.

What are you going to contribute?

This FR and the earlier discussion responses👍

No time available to commit to moving this forward myself, stale-bot can close it if there's minimal engagement.

simonwiles commented 1 year ago

OP from #3523 here -- thank you for the FR. I can meet my need by manually editing the postfix-virtual.cf file so I'm happy (thanks!), but if there's interest in enabling and documenting this with DMS/setup.sh I'd be willing to work on implementing that (i.e. writing it up for the docs and/or working on the script to provide appropriate information/warnings/feedback).

polarathene commented 1 year ago

if there's interest in enabling and documenting this with DMS / setup.sh

Maybe if another user expresses interest.

It'd definitely be good to know if we have other users that need to ensure mail is delivered to a local account and also always forwarded to other recipient(s), which may require DMS to allow supporting self-referencing aliases that overlap with an actual mail account.


Just to clarify your use-case:

Clarification would help to understand that this isn't an XY problem. Especially since:

I'm loathe to try to persuade a bunch of (mostly older) academics across four continents to change the way they're used to working

How does the above translate into "the way they're used to working"?

simonwiles commented 1 year ago

Oof, seems I didn't reply to this, I'm sorry (issue is essentially resolved in #3523). Yes, that is precisely the use-case I'm interested in (and, to be clear, currently have working 100% acceptably with DMS v12.1.0) -- or two use cases, if forwarding to one external address is one use-case, and forwarding to more than one external address is a second use-case.

I'm migrating a mail server for an academic professional organization (the mailserver has been operated as part of Plesk for years) and (most of) the academics who serve as officers are used to receiving email for president@, secretary@, admissions@ etc. at their own personal addresses and don't want to have to check another mailbox (or worry about passwords etc.) -- however, we do want inbound correspondence to be stored on the server for archival purposes, and available to new incumbents when officers rotate in and out of roles.

florian-asche commented 3 weeks ago

+1