Unset mydestination in postfix/main.cf#3264
Unset mydestination in postfix/main.cf#3264jrpear wants to merge 16 commits intodocker-mailserver:masterfrom jrpear:unset-mydestination
mydestination in postfix/main.cf#3264Conversation
|
Not sure if this counts as breaking. Marked it for v12.1.0, but v13.0.0 is also fine - just change it if you guys think this is breaking. |
|
The fact the test require being removed (failures?) implies a breaking change 🤔 Delay until v13 @jrpear I saw your detailed comment with references to issues and PRs, that is very appreciated and I'll try go through that tomorrow 👍 IIRC we have I am aware of a case on the docs that uses a Do the tests pass if you only dropped the
Scripts default add the docker-mailserver/target/scripts/helpers/aliases.sh Lines 48 to 55 in 03772f6 Which in tests was being caught by the regexp alias for postmaster to redirect to the user mail account: I don't think we have sufficient test coverage on this particular change to have as much confidence as I'd like, but that's not been an easy goal to reach. I'll go over the detailed comment in the associated issue tomorrow to review the history. |
| !!! tip "You might not want a bare domain" | ||
|
|
||
| We encourage you to consider using a subdomain where possible. | ||
|
|
||
| - There are [benefits][github-comment-baredomain] to preferring a subdomain. | ||
| - A bare domain is not required to have `[email protected]`, that is distinct from your hostname which is identified by a DNS MX record. |
There was a problem hiding this comment.
Not sure about dropping this, or some other parts of this section that may be useful to keep in docs?
I'll chime in again after a proper review.
There was a problem hiding this comment.
My reading of the linked issue explaining benefits is:
You should host marketing emails and transactional emails on different domains so that your transactional emails aren't marked as spam even if your marketing emails are marked as spam.
That doesn't support hosting your mail for [email protected] at mail.example.com rather than example.com. It is good advice for deliverability though.
We could move it under Why are my emails not being delivered?
|
|
||
| # Add DOMAINNAME (not an ENV, set by `helpers/dns.sh`) to vhost. | ||
| # NOTE: `setup-stack.sh:_setup_ldap` has related logic: | ||
| # - `main.cf:mydestination` setting removes `$mydestination` as an LDAP bugfix. |
There was a problem hiding this comment.
This mentions that mydestination only dropped $mydestination, the localhost entries aren't used by anything? (would have expected it to just clear the whole setting otherwise)
There was a problem hiding this comment.
They're not used by anything now as far as I can tell, but they would be if we set myorigin = localhost like I described in my comment below.
Alright, I'll see if I can find that
Ah, good spot. I don't think that trick is working around the current config, I think the trick would no longer work with this change because the trick needs to send mail to a system user. There is another way to discard mail sent to a particular address. I haven't decided whether I think it's best to allow any mail to be sent to system users. I'd prefer totally disallowing it because it'd make our postfix config easier to understand; we would know that all email was being delivered by
I think you meant "if you only dropped the Not the simplest solution, but probably the easiest solution (I'm referencing simple made easy).
Ah yes, if we do remove delivery to local users then this would need to be removed too.
There's never enough tests 😄 If there's a relevant test I could write that would help check the safety of this change, let me know. |
|
I've read your feedback here and it seems pretty good 👍 I didn't manage to find time to look further into this for the proper review, I'll try again tomorrow 😅 If I get too swamped to participate in further review, I am happy with your feedback and effort to document the motivation supporting the change. You have my approval at present 😀 |
|
Summary so far: There's another solution to this problem which probably isn't breaking and makes things a bit more complicated: Todo to make my preferred change safer and better:
|
|
I couldn't find any mail sent by a A grep in the whole repo for "root" found no messages whose hard-coded destination was 'root'. I can't find any great documentation for Amavis, but I think it delivers virus notifications to So that should be fine. I haven't managed to understand how to configure Amavis or how it communicates with Postfix so I'm not going to try to write a test. |
|
This looks already very good to me 👍🏼 Good job! The only thing I wish for are some tests, even if they are few and small (if writing such tests is feasible and makes sense, of course) ❤️ |
|
I made the existing tests drive this change in 3508485 (not the best commit message as no tests are added). After that commit, several tests fail. After applying 5366c90 and 5519536, all the tests pass again. I can't think of any other tests to write to verify this, but I'm open to suggestions. Hopefully later today I'll investigate the alias thing and fix that FAQ. |
|
I'm not sure what to make of the test that failed to pass CI. It passes on my computer. The line that fails is the second time the command has been run (the first being on the previous line). Edit: will look into it more another time. |
polarathene
left a comment
There was a problem hiding this comment.
Continuing my investigation, but thought this might be relevant to discuss.
@localhostmight be a bit weird to receive mail from (should mostly be internal though, and usually only to the postmaster/admin account? Except for bounces fromMAILER-DAEMON). If it does leave DMS, it should definitely not be via a sender address likeroot@localhostwhich the current change proposal would cause.postmaster(address thatMAILER-DAEMONwill send notifications to) is not configured by us atm, so should fail delivery silently.- Sending mail to local (system) users is valid, but I don't think anyone is expecting them to be delivered to
/var/mailmailbox files that aren't managed by Dovecot (virtual mailboxes). Supposedly these should all be aliased to the postmaster mailbox. mydestinationprovides validation for recipient addresses to these local (system) users. We could unsetmydestinationand rely on@localhostas a virtual alias to an actual mailbox (eg: Postmaster), but this would skip validation (perhaps no longer important if we direct all of it to a single mailbox anyway..?).
| mydestination = localhost | ||
| myorigin = localhost |
There was a problem hiding this comment.
During my own research into this, I was thinking this would be good too, but it can affect communication with external MTAs.
I've setup a couple DMS instances locally in a VM and a ThunderBird client setup for an account on each instance. For testing with local system accounts I'd send mail via sendmail within the container.
- If I send mail to
[email protected]from an@example.testaccount, then I'll get a bounce mail regarding my message could not be delivered since thefake-useraccount doesn't exist. The sender of the bounce notification isMAILER-DAEMON@localhost. - If I instead send to the
example.testfake address from another DMS instance (such as@whatever.test), the bounce notification will be from that instances[email protected]account.mail.whatever.testinstance is using v12myorigin/mydestinationadjustments, whilemail.example.testis using thelocahostvalues proposed in this PR. - If
rootor any other local account inmail.example.testsends out mail to an external MTA such asmail.whatever.test, this will still use aroot@localhostaddress. Obviously not good, and would likely be considered spam.- I'm not sure if anyone has a system account sending mail outbound directly (instead of aliased like with Postmaster).
- If
mail.whatever.testchangesmydestinationto not includelocalhost, the mail is rejected as the FROM/sender address is subject to MX lookup apparently? So matchingmydestinationtechnically bypasses that check (although my containers in this case are all in the same subnet which is possibly ignoringsmtpd_recipient_restrictions).
There is a few ways to avoid that localhost issue.
- With outbound mail,
smtp_generic_mapscould ensure@$mydomainreplaces@localhost, but may appear as an address you could reply to, and potentially conflict with an existing virtual mailbox managed by Dovecot. canonical_mapscan rewrite envelope and header addresses for sender, recipient or both. Not good for sender address if that affects inbound mail with a third-party mail claiming to be from@localhostthough, or rewriting recipient@localhostat this stage would missmydestinationmatching it (unless configured for that domain also).
These accounts shouldn't be receiving mail in the first place AFAIK, not from non-system senders at least.
I will cover this in more detail when I'm done with my write-up (and you probably already know a bunch of this yourself), but mydestination identifies what domains should be considered for handing to the local delivery agent. Once qualified as local class, mail with a recipient address matching only the local-part in /etc/passwd or /etc/aliases gets delivered to /var/mail/<username> (single file, not managed by Dovecot).
Unless /etc/aliases maps to a domain outside of mydestination like we do for root to the virtual mailbox of Postmaster.
Keep in mind that both local and virtual aliases rewrite the recipient address, not sender. So mail from root remains as root@$myorigin sender address; only mail delivered to root / root@$myorigin would be redirected to the postmaster address instead.
With our present myorigin=$myhostname and mydestination=$myhostname (ignoring the localhost domains), the above works as intended.
- With bare domains, of course this overlaps with the virtual mailbox Dovecot manages, so we advise to remove the
mydestinationvalue in our docs FAQ entry.- Now the system accounts appending
@$myoriginaren't considered local, and try to deliver to Dovecot, but the account typically won't exist and fail delivery. - This bounces back to the sender address that is also local and fails the same way (double bounce is caught and avoids a mail loop of bounce ping-pong AFAIK).
- Unlike the FQDN
mail.example.com, the bare domainexample.comwould thus be sending mail into a void.
- Now the system accounts appending
- Whereas with
mail.example.com, when Amavis sends mail andmydestinationis unset (or doesn't have a match for$myorigin), unlike the bare domain, Postfix doesn't recognize the address as a final delivery destination it should be responsible for handling, so it attempts to deliver it outbound - but realizes that resolves back to itself and avoids a loop. Mail void as well.
Technically, Postfix can configure the Postmaster address to communicate the admin about this sort of issue, but we don't have that enabled by default (nor do we alias postmaster in /etc/aliases to notify anyone, like the Postmaster mailbox root aliases to).
Additional observations:
- Local/System user mailboxes created in
/var/mailwill originally have ownership assigned to that user, but once a change detection occurs or DMS is restarted, ownership will be reassigned to thedockeruser, and any future mail for that recipient user will fail to be delivered due to lack of permissions on it's own mailbox file. So we don't really support local mailbox delivery either 😅 luser_relayseems neat, but even whenlocal_recipient_mapsis unset, any system user will still be ignored and store mail in/var/mail, the maps lookup is only to validate if mail should be rejected because the user doesn't exist. So we technically want to keep this validation for system users as recipients?
This is why I'm hesitant towards fixes for such settings, as there are a lot more scenarios to also consider. I don't want to accidentally introduce further regressions 😅
I think we can address this config issue and get consistency between both types of hostname configs. I need to give it some more thought.
Yeah this was my experience as well when looking into the recent I used the official Amavis docs (although I guess you found that 😅 ) and a few third-party sites that explained things in better detail. There's also the Amavis Gitlab repo which is sometimes helpful. Other times I looked through the config within the container, especially since we have a few modifications of our own and from Debian there.
I haven't looked through these Amavis docs on Postfix integration, but assume that our config is based on that. I am aware of an issue with ports 587 / 465 being subject to Amavis filtering which may not be desirable. Neither is too concerning though as we're looking at deprecating Amavis in future in favor of Rspamd. |
Kind of want to agree, but it also kind of makes sense for the system accounts and that kind of mail to be distinct? It's probably easier to manage and validate with It's just the usage of bare-domains that complicates it a bit more 😛 (but it turns out there are cases where users also want the domain-part of an address with their accounts to use the full hostname too 🤷♂️ ) Common
|
|
Documentation preview for this PR is ready! 🎉 Built with commit: 75571ca |
|
@polarathene I've finally got to read and think through what you wrote out. It seems that this change is a lot more complicated than I thought it would be. I've run out of interest in solving this. I've pushed a revert to the first solution: unsetting I'm going to move on from DMS, so I won't be able to provide any support or fixes for bugs this might introduce. This is a great project, you're all so friendly and generous with your time. Good luck! |
No worries! :) If you don't mind did you choose a different open-source project, a service like SendGrid or something else? |
|
@polarathene do you think we should merge this PR then? |
No, but That said, it is easier to just recommend |
I decided to try mox, an attempt at reimplementing the whole Postfix, Dovecot, SpamAssassin, OpenDKIM, etc. suite in one program (maybe even one process?). It seems like the right way to do a small email server, but it's very young. Hopefully it isn't abandoned. |
I am too short on time to work in this as well now. We can keep it in mind for the future though.
Yes 👍🏼
👍🏼 Can you update the docs with a short (really) note?:) |
Linking back to this PR from the bare domain FAQ entry? Or a maintainers / contributors page for awareness? |
Whatever you deem to be the better option. Preferably the way that involves less work (so probably option 1: link back per FAQ?). |
|
Superseeded by #3316 |
Description
Unset
mydestinationto support bare domains without any special configuration.I laid out the justification and what I could find of the history of this in #3197, which this will fulfill.
Type of change
If anyone is sending mail to a system user using
docker exec sendmailordocker execsome other program, they won't be able to do so after this change. I considered this here.Checklist:
docs/)