handle multiple emails in header 'To'
This commit is contained in:
@@ -275,7 +275,7 @@ func (e *parentEmail) fixtofrom(newSenderMailbox string, domains []string) {
|
|||||||
|
|
||||||
// Recipients returns list of recipients (to, cc)
|
// Recipients returns list of recipients (to, cc)
|
||||||
func (e parentEmail) Recipients() []string {
|
func (e parentEmail) Recipients() []string {
|
||||||
return append(email.AddressList(e.CC), e.To)
|
return append(email.AddressList(e.CC), strings.Split(email.Address(e.To), ",")...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) getParentEvent(evt *event.Event) (id.EventID, *event.Event) {
|
func (b *Bot) getParentEvent(evt *event.Event) (id.EventID, *event.Event) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func New(messageID, inReplyTo, references, subject, from, to, rcptto, cc, text,
|
|||||||
From: Address(from),
|
From: Address(from),
|
||||||
To: Address(to),
|
To: Address(to),
|
||||||
CC: AddressList(cc),
|
CC: AddressList(cc),
|
||||||
RcptTo: rcptto,
|
RcptTo: Address(rcptto),
|
||||||
Subject: subject,
|
Subject: subject,
|
||||||
Text: text,
|
Text: text,
|
||||||
HTML: html,
|
HTML: html,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
@@ -26,6 +27,10 @@ func MessageID(eventID id.EventID, domain string) string {
|
|||||||
func Address(email string) string {
|
func Address(email string) string {
|
||||||
addr, _ := mail.ParseAddress(email) //nolint:errcheck // if it fails here, nothing will help
|
addr, _ := mail.ParseAddress(email) //nolint:errcheck // if it fails here, nothing will help
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
|
list := AddressList(email)
|
||||||
|
if len(list) > 0 {
|
||||||
|
return strings.Join(list, ",")
|
||||||
|
}
|
||||||
return email
|
return email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user