mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 06:34:40 +03:00
add aliases/lists: when sending to an alias, the message gets delivered to all members
the members must currently all be addresses of local accounts. a message sent to an alias is accepted if at least one of the members accepts it. if no members accepts it (e.g. due to bad reputation of sender), the message is rejected. if a message is submitted to both an alias addresses and to recipients that are members of the alias in an smtp transaction, the message will be delivered to such members only once. the same applies if the address in the message from-header is the address of a member: that member won't receive the message (they sent it). this prevents duplicate messages. aliases have three configuration options: - PostPublic: whether anyone can send through the alias, or only members. members-only lists can be useful inside organizations for internal communication. public lists can be useful for support addresses. - ListMembers: whether members can see the addresses of other members. this can be seen in the account web interface. in the future, we could export this in other ways, so clients can expand the list. - AllowMsgFrom: whether messages can be sent through the alias with the alias address used in the message from-header. the webmail knows it can use that address, and will use it as from-address when replying to a message sent to that address. ideas for the future: - allow external addresses as members. still with some restrictions, such as requiring a valid dkim-signature so delivery has a chance to succeed. will also need configuration of an admin that can receive any bounces. - allow specifying specific members who can sent through the list (instead of all members). for github issue #57 by hmfaysal. also relevant for #99 by naturalethic. thanks to damir & marin from sartura for discussing requirements/features.
This commit is contained in:
149
main.go
149
main.go
@ -148,6 +148,14 @@ var commands = []struct {
|
||||
{"config address rm", cmdConfigAddressRemove},
|
||||
{"config domain add", cmdConfigDomainAdd},
|
||||
{"config domain rm", cmdConfigDomainRemove},
|
||||
{"config alias list", cmdConfigAliasList},
|
||||
{"config alias print", cmdConfigAliasPrint},
|
||||
{"config alias add", cmdConfigAliasAdd},
|
||||
{"config alias update", cmdConfigAliasUpdate},
|
||||
{"config alias rm", cmdConfigAliasRemove},
|
||||
{"config alias addaddr", cmdConfigAliasAddaddr},
|
||||
{"config alias rmaddr", cmdConfigAliasRemoveaddr},
|
||||
|
||||
{"config describe-sendmail", cmdConfigDescribeSendmail},
|
||||
{"config printservice", cmdConfigPrintservice},
|
||||
{"config ensureacmehostprivatekeys", cmdConfigEnsureACMEHostprivatekeys},
|
||||
@ -711,6 +719,147 @@ func ctlcmdConfigDomainRemove(ctl *ctl, d dns.Domain) {
|
||||
fmt.Printf("domain removed, remember to remove dns records for %s\n", d)
|
||||
}
|
||||
|
||||
func cmdConfigAliasList(c *cmd) {
|
||||
c.params = "domain"
|
||||
c.help = `List aliases for domain.`
|
||||
args := c.Parse()
|
||||
if len(args) != 1 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasList(xctl(), args[0])
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasList(ctl *ctl, address string) {
|
||||
ctl.xwrite("aliaslist")
|
||||
ctl.xwrite(address)
|
||||
ctl.xreadok()
|
||||
ctl.xstreamto(os.Stdout)
|
||||
}
|
||||
|
||||
func cmdConfigAliasPrint(c *cmd) {
|
||||
c.params = "alias"
|
||||
c.help = `Print settings and members of alias.`
|
||||
args := c.Parse()
|
||||
if len(args) != 1 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasPrint(xctl(), args[0])
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasPrint(ctl *ctl, address string) {
|
||||
ctl.xwrite("aliasprint")
|
||||
ctl.xwrite(address)
|
||||
ctl.xreadok()
|
||||
ctl.xstreamto(os.Stdout)
|
||||
}
|
||||
|
||||
func cmdConfigAliasAdd(c *cmd) {
|
||||
c.params = "alias@domain rcpt1@domain ..."
|
||||
c.help = `Add new alias with one or more addresses.`
|
||||
args := c.Parse()
|
||||
if len(args) < 2 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
alias := config.Alias{Addresses: args[1:]}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasAdd(xctl(), args[0], alias)
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasAdd(ctl *ctl, address string, alias config.Alias) {
|
||||
ctl.xwrite("aliasadd")
|
||||
ctl.xwrite(address)
|
||||
xctlwriteJSON(ctl, alias)
|
||||
ctl.xreadok()
|
||||
}
|
||||
|
||||
func cmdConfigAliasUpdate(c *cmd) {
|
||||
c.params = "alias@domain [-postpublic false|true -listmembers false|true -allowmsgfrom false|true]"
|
||||
c.help = `Update alias configuration.`
|
||||
var postpublic, listmembers, allowmsgfrom string
|
||||
c.flag.StringVar(&postpublic, "postpublic", "", "whether anyone or only list members can post")
|
||||
c.flag.StringVar(&listmembers, "listmembers", "", "whether list members can list members")
|
||||
c.flag.StringVar(&allowmsgfrom, "allowmsgfrom", "", "whether alias address can be used in message from header")
|
||||
args := c.Parse()
|
||||
if len(args) != 1 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
alias := args[0]
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasUpdate(xctl(), alias, postpublic, listmembers, allowmsgfrom)
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasUpdate(ctl *ctl, alias, postpublic, listmembers, allowmsgfrom string) {
|
||||
ctl.xwrite("aliasupdate")
|
||||
ctl.xwrite(alias)
|
||||
ctl.xwrite(postpublic)
|
||||
ctl.xwrite(listmembers)
|
||||
ctl.xwrite(allowmsgfrom)
|
||||
ctl.xreadok()
|
||||
}
|
||||
|
||||
func cmdConfigAliasRemove(c *cmd) {
|
||||
c.params = "alias@domain"
|
||||
c.help = "Remove alias."
|
||||
args := c.Parse()
|
||||
if len(args) != 1 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasRemove(xctl(), args[0])
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasRemove(ctl *ctl, alias string) {
|
||||
ctl.xwrite("aliasrm")
|
||||
ctl.xwrite(alias)
|
||||
ctl.xreadok()
|
||||
}
|
||||
|
||||
func cmdConfigAliasAddaddr(c *cmd) {
|
||||
c.params = "alias@domain rcpt1@domain ..."
|
||||
c.help = `Add addresses to alias.`
|
||||
args := c.Parse()
|
||||
if len(args) < 2 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasAddaddr(xctl(), args[0], args[1:])
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasAddaddr(ctl *ctl, alias string, addresses []string) {
|
||||
ctl.xwrite("aliasaddaddr")
|
||||
ctl.xwrite(alias)
|
||||
xctlwriteJSON(ctl, addresses)
|
||||
ctl.xreadok()
|
||||
}
|
||||
|
||||
func cmdConfigAliasRemoveaddr(c *cmd) {
|
||||
c.params = "alias@domain rcpt1@domain ..."
|
||||
c.help = `Remove addresses from alias.`
|
||||
args := c.Parse()
|
||||
if len(args) < 2 {
|
||||
c.Usage()
|
||||
}
|
||||
|
||||
mustLoadConfig()
|
||||
ctlcmdConfigAliasRmaddr(xctl(), args[0], args[1:])
|
||||
}
|
||||
|
||||
func ctlcmdConfigAliasRmaddr(ctl *ctl, alias string, addresses []string) {
|
||||
ctl.xwrite("aliasrmaddr")
|
||||
ctl.xwrite(alias)
|
||||
xctlwriteJSON(ctl, addresses)
|
||||
ctl.xreadok()
|
||||
}
|
||||
|
||||
func cmdConfigAccountAdd(c *cmd) {
|
||||
c.params = "account address"
|
||||
c.help = `Add an account with an email address and reload the configuration.
|
||||
|
Reference in New Issue
Block a user