fix: properly quote email sender names containing @ symbols (#1768)

When user names contain @ symbols, the email library fails to parse
the sender address format "Name @ Symbol via Vikunja <email@domain.com>".
This fix uses Go's net/mail.Address to properly format the sender
address according to RFC 5322, which automatically quotes names
containing special characters.

Fixes the error: "getting sender address: no FROM address set"
This commit is contained in:
Weijie Zhao
2025-11-07 18:44:24 +08:00
committed by GitHub
parent 77779350d2
commit 4fe0763010

View File

@@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/mail"
"reflect"
"strconv"
"time"
@@ -175,7 +176,12 @@ func (u *User) GetName() string {
// GetNameAndFromEmail returns the name and email address for a user. Useful to use in notifications.
func (u *User) GetNameAndFromEmail() string {
return u.GetName() + " via Vikunja <" + config.MailerFromEmail.GetString() + ">"
// Use RFC 5322 compliant address formatting to properly handle special characters like @ in names
addr := mail.Address{
Name: u.GetName() + " via Vikunja",
Address: config.MailerFromEmail.GetString(),
}
return addr.String()
}
func (u *User) GetFailedTOTPAttemptsKey() string {