Skip to content

Commit 557a161

Browse files
author
Winni Neessen
committed
Fix in address handling and more header related methods
1 parent 066b421 commit 557a161

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

header.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const (
2020
// HeaderContentLang is the "Content-Language" header
2121
HeaderContentLang Header = "Content-Language"
2222

23+
// HeaderContentLocation is the "Content-Location" header (RFC 2110)
24+
HeaderContentLocation Header = "Content-Location"
25+
2326
// HeaderContentTransferEnc is the "Content-Transfer-Encoding" header
2427
HeaderContentTransferEnc Header = "Content-Transfer-Encoding"
2528

@@ -50,6 +53,9 @@ const (
5053
// See: https://datatracker.ietf.org/doc/html/rfc2045#section-4
5154
HeaderMIMEVersion Header = "MIME-Version"
5255

56+
// HeaderOrganization is the "Organization" header field
57+
HeaderOrganization Header = "Organization"
58+
5359
// HeaderPrecedence is the "Precedence" header field
5460
HeaderPrecedence Header = "Precedence"
5561

@@ -62,6 +68,12 @@ const (
6268
// HeaderSubject is the "Subject" header field
6369
HeaderSubject Header = "Subject"
6470

71+
// HeaderUserAgent is the "User-Agent" header field
72+
HeaderUserAgent Header = "User-Agent"
73+
74+
// HeaderXMailer is the "X-Mailer" header field
75+
HeaderXMailer Header = "X-Mailer"
76+
6577
// HeaderXMSMailPriority is the "X-MSMail-Priority" header field
6678
HeaderXMSMailPriority Header = "X-MSMail-Priority"
6779

msg.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (m *Msg) SetHeader(h Header, v ...string) {
151151
func (m *Msg) SetAddrHeader(h AddrHeader, v ...string) error {
152152
var al []*mail.Address
153153
for _, av := range v {
154-
a, err := mail.ParseAddress(m.encodeString(av))
154+
a, err := mail.ParseAddress(av)
155155
if err != nil {
156156
return fmt.Errorf("failed to parse mail address header %q: %w", av, err)
157157
}
@@ -337,6 +337,17 @@ func (m *Msg) SetImportance(i Importance) {
337337
m.SetHeader(HeaderXMSMailPriority, i.NumString())
338338
}
339339

340+
// SetOrganization sets the provided string as Organization header for the Msg
341+
func (m *Msg) SetOrganization(o string) {
342+
m.SetHeader(HeaderOrganization, o)
343+
}
344+
345+
// SetUserAgent sets the User-Agent/X-Mailer header for the Msg
346+
func (m *Msg) SetUserAgent(a string) {
347+
m.SetHeader(HeaderUserAgent, a)
348+
m.SetHeader(HeaderXMailer, a)
349+
}
350+
340351
// GetSender returns the currently set FROM address. If f is true, it will return the full
341352
// address string including the address name, if set
342353
func (m *Msg) GetSender(ff bool) (string, error) {

0 commit comments

Comments
 (0)