-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1:N address expansion #401
Comments
maddy supports forwarding ("address rewriting") but it is currently limited to 1-to-1. That is, root@domain.com could be aliased to alice@domain.com or bob@domain.com or bob@otherdomain.com (requires additional configuration if otherdomain.com is not handled by the same server, https://maddy.email/tutorials/alias-to-remote/). |
Yes my interest is in the other situations, such as 1:n with n greater than one. My main problem right now is that I would like to have mail addressing postmaster being read by more than one person. And for 1:1, in the situation it would be nice to have a copy of the mail both in root@domain.com mail storage and in the one of bob@otherdomain.com . |
I am also interested in the 1:N address expansion and trying to add a PR. My thinking would be to make maddy/internal/msgpipeline/msgpipeline.go Lines 309 to 364 in 85d3648
Do you think that I am in the right track? Also, what separator should we take? A comma separated lists? |
Yeah, that should work. Assuming we keep current naive handling of partial failures, but I would prefer to leave that can of worms for later.
Better hope no-one uses a |
Thanks for confirming! I will start working on it - I was checking first I could run all testcases so I ensure I do not break anything as I start with the changes. I am all for the opinionated as it makes the rules easier to read/understand. I proposed |
Agreed. People with weird addresses can use other data sources (e.g. SQL database) that have no similar problems. P.S. There is some existing code that you probably want to use, some module.Table implementations have optional LookupMulti method that returns multiple entries. It probably should be used by rewrite_rcpt implementation if available. And then file-based implementation should be adjusted to use |
ok, I will then use LookupMulti when possible and default to |
Is it enough to keep reading until the next unescaped ", after encountering a "? In this case a modification to the string split algorithm should suffice. Also, is it going to be a problem if someone puts something like
or
? |
This is a nop but should not result an infinite loop This would also be a nop after replacing a->b->a. This is not really related to the 1:N, is it? This type of config is valid today. We cannot assume " in the email addresses (most will not), so using string splits with |
I think if LookupMulti is not defined then you should not do any splitting on singular value returned by Lookup. This will cause problems with all other non-file based table implementations.
I believe
table.file is also re-used for other values that are not email address, I would prefer to keep parser as content-unaware as possible.
P.S. As described in replace_rcpt documentation, it does only one replacement step - aliases are not resolved recursively. |
Not really, I was wondering about a situation like this (or some faulty version)
but one could just replace root with the addresses in the config file, so it's not necessary. I was worried about possible loops, since I saw AddRcpt calling itself. Thank you both for your replies. |
I have not implemented the
UpdateImplemented the
So it is ready for review. |
Regarding commas in email addresses, the last paragraph of RFC5322 section 3.4 reserves semicolons for this use case (separating email addresses and treating them as a group). eg:
|
What is the reason for using semicolons, though? |
Mainly that, in theory, someone might want to use
Great - please notice that, as they both touch a common file the second PR you merge will need to be rebased. I did that in my fork as I have been running with both patches in my email server. |
Both addresses you provided are valid but would need to have local-part quoted. That is |
Implemented in bc42464. |
Use case
It it described on wikipedia:
Role-addresses
info, sales, postmaster, and similar names[6] can appear to the left of @ in email addresses. An organization may forward messages intended for a given role to the address of the person(s) currently functioning in that role or office.
Multiple, or discontinued addresses
When users change their email address, or have several addresses, the user or an administrator may set up forwarding from these addresses, if still valid, to a single current one, in order to avoid losing messages.
Your idea for a solution
I haven't looked at the source code of maddy. It would be nice to store forward rules in a table such as
and so when a mail is received the To header would be checked against "root@domain.com" and automatically forwarded to "alice@domain.com", "bob@domain.com" and "bob@otherdomain.com". The table could be altered (and reloaded?) via the command line or other mechanisms.
I'm not sure how difficult would that be.
The text was updated successfully, but these errors were encountered: