mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-15 02:12:55 +01:00
Improve BccFromString to handle spaces and empty addresses
Trim spaces from email addresses and skip empty addresses in BccFromString method. This ensures that the BCC list only includes valid, non-empty email addresses, enhancing email sending reliability.
This commit is contained in:
parent
03cb09c3bd
commit
f079ea09eb
1 changed files with 10 additions and 1 deletions
11
msg.go
11
msg.go
|
@ -942,7 +942,16 @@ func (m *Msg) BccIgnoreInvalid(rcpts ...string) {
|
||||||
// References:
|
// References:
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.3
|
||||||
func (m *Msg) BccFromString(rcpts string) error {
|
func (m *Msg) BccFromString(rcpts string) error {
|
||||||
return m.Bcc(strings.Split(rcpts, ",")...)
|
src := strings.Split(rcpts, ",")
|
||||||
|
var dst []string
|
||||||
|
for _, address := range src {
|
||||||
|
address = strings.TrimSpace(address)
|
||||||
|
if address == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dst = append(dst, address)
|
||||||
|
}
|
||||||
|
return m.Bcc(dst...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplyTo sets the "Reply-To" address for the Msg, specifying where replies should be sent.
|
// ReplyTo sets the "Reply-To" address for the Msg, specifying where replies should be sent.
|
||||||
|
|
Loading…
Reference in a new issue