Skip to content

Commit b56b66c

Browse files
authored
Merge pull request #498 from wneessen/bugfix/497_address-name-is-not-included-in-header
Refactored address handling for improved consistency and formatting
2 parents 42e92cf + a08e65e commit b56b66c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ package mail
1111

1212
// VERSION indicates the current version of the package. It is also attached to the default user
1313
// agent string.
14-
const VERSION = "0.7.1"
14+
const VERSION = "0.7.2"

msg.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,9 +1496,9 @@ func (m *Msg) GetSender(useFullAddr bool) (string, error) {
14961496
}
14971497
}
14981498

1499-
addr := from[0]
1499+
addr := *from[0]
15001500
if !useFullAddr {
1501-
addr.Name = ""
1501+
return mailAddressStringWithoutName(addr), nil
15021502
}
15031503
return addr.String(), nil
15041504
}
@@ -1524,8 +1524,7 @@ func (m *Msg) GetRecipients() ([]string, error) {
15241524
continue
15251525
}
15261526
for _, r := range addresses {
1527-
r.Name = ""
1528-
rcpts = append(rcpts, r.String())
1527+
rcpts = append(rcpts, mailAddressStringWithoutName(*r))
15291528
}
15301529
}
15311530
if len(rcpts) <= 0 {
@@ -3327,3 +3326,8 @@ func writeFuncFromBuffer(buffer *bytes.Buffer) func(io.Writer) (int64, error) {
33273326
}
33283327
return writeFunc
33293328
}
3329+
3330+
func mailAddressStringWithoutName(addr mail.Address) string {
3331+
addr.Name = ""
3332+
return addr.String()
3333+
}

0 commit comments

Comments
 (0)