mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-08 00:36:47 +00:00
fix: RFC1342 encode sender name that goes in from header (#8193)
# Which Problems Are Solved - Some smtp server/client combination may have problems with non-ASCII sender names for example using an umlaut # How the Problems Are Solved - The same RFC1342 mechanism that was added in #https://github.com/zitadel/zitadel/pull/6637 and later improved by @eliobischof with BEncoding has been added to the sender name that goes in the From header # Additional Context - Closes #7976
This commit is contained in:
parent
da592ccf57
commit
14aeb42cc2
@ -34,7 +34,7 @@ func (msg *Email) GetContent() (string, error) {
|
|||||||
headers := make(map[string]string)
|
headers := make(map[string]string)
|
||||||
from := msg.SenderEmail
|
from := msg.SenderEmail
|
||||||
if msg.SenderName != "" {
|
if msg.SenderName != "" {
|
||||||
from = fmt.Sprintf("%s <%s>", msg.SenderName, msg.SenderEmail)
|
from = fmt.Sprintf("%s <%s>", bEncodeWord(msg.SenderName), msg.SenderEmail)
|
||||||
}
|
}
|
||||||
headers["From"] = from
|
headers["From"] = from
|
||||||
if msg.ReplyToAddress != "" {
|
if msg.ReplyToAddress != "" {
|
||||||
@ -55,7 +55,7 @@ func (msg *Email) GetContent() (string, error) {
|
|||||||
if !isHTML(msg.Content) {
|
if !isHTML(msg.Content) {
|
||||||
mime = "MIME-Version: 1.0" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\"" + lineBreak + lineBreak
|
mime = "MIME-Version: 1.0" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\"" + lineBreak + lineBreak
|
||||||
}
|
}
|
||||||
subject := "Subject: " + bEncodeSubject(msg.Subject) + lineBreak
|
subject := "Subject: " + bEncodeWord(msg.Subject) + lineBreak
|
||||||
message += subject + mime + lineBreak + msg.Content
|
message += subject + mime + lineBreak + msg.Content
|
||||||
|
|
||||||
return message, nil
|
return message, nil
|
||||||
@ -70,6 +70,6 @@ func isHTML(input string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns a RFC1342 "B" encoded string to allow non-ascii characters
|
// returns a RFC1342 "B" encoded string to allow non-ascii characters
|
||||||
func bEncodeSubject(subject string) string {
|
func bEncodeWord(word string) string {
|
||||||
return mime.BEncoding.Encode("UTF-8", subject)
|
return mime.BEncoding.Encode("UTF-8", word)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user