Skip to content

Commit 4fe0763

Browse files
authored
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 protected]>". 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"
1 parent 7777935 commit 4fe0763

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/user/user.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"errors"
2222
"fmt"
23+
"net/mail"
2324
"reflect"
2425
"strconv"
2526
"time"
@@ -175,7 +176,12 @@ func (u *User) GetName() string {
175176

176177
// GetNameAndFromEmail returns the name and email address for a user. Useful to use in notifications.
177178
func (u *User) GetNameAndFromEmail() string {
178-
return u.GetName() + " via Vikunja <" + config.MailerFromEmail.GetString() + ">"
179+
// Use RFC 5322 compliant address formatting to properly handle special characters like @ in names
180+
addr := mail.Address{
181+
Name: u.GetName() + " via Vikunja",
182+
Address: config.MailerFromEmail.GetString(),
183+
}
184+
return addr.String()
179185
}
180186

181187
func (u *User) GetFailedTOTPAttemptsKey() string {

0 commit comments

Comments
 (0)