mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Fix in address handling and more header related methods
This commit is contained in:
parent
066b421725
commit
557a161a12
2 changed files with 24 additions and 1 deletions
12
header.go
12
header.go
|
@ -20,6 +20,9 @@ const (
|
||||||
// HeaderContentLang is the "Content-Language" header
|
// HeaderContentLang is the "Content-Language" header
|
||||||
HeaderContentLang Header = "Content-Language"
|
HeaderContentLang Header = "Content-Language"
|
||||||
|
|
||||||
|
// HeaderContentLocation is the "Content-Location" header (RFC 2110)
|
||||||
|
HeaderContentLocation Header = "Content-Location"
|
||||||
|
|
||||||
// HeaderContentTransferEnc is the "Content-Transfer-Encoding" header
|
// HeaderContentTransferEnc is the "Content-Transfer-Encoding" header
|
||||||
HeaderContentTransferEnc Header = "Content-Transfer-Encoding"
|
HeaderContentTransferEnc Header = "Content-Transfer-Encoding"
|
||||||
|
|
||||||
|
@ -50,6 +53,9 @@ const (
|
||||||
// See: https://datatracker.ietf.org/doc/html/rfc2045#section-4
|
// See: https://datatracker.ietf.org/doc/html/rfc2045#section-4
|
||||||
HeaderMIMEVersion Header = "MIME-Version"
|
HeaderMIMEVersion Header = "MIME-Version"
|
||||||
|
|
||||||
|
// HeaderOrganization is the "Organization" header field
|
||||||
|
HeaderOrganization Header = "Organization"
|
||||||
|
|
||||||
// HeaderPrecedence is the "Precedence" header field
|
// HeaderPrecedence is the "Precedence" header field
|
||||||
HeaderPrecedence Header = "Precedence"
|
HeaderPrecedence Header = "Precedence"
|
||||||
|
|
||||||
|
@ -62,6 +68,12 @@ const (
|
||||||
// HeaderSubject is the "Subject" header field
|
// HeaderSubject is the "Subject" header field
|
||||||
HeaderSubject Header = "Subject"
|
HeaderSubject Header = "Subject"
|
||||||
|
|
||||||
|
// HeaderUserAgent is the "User-Agent" header field
|
||||||
|
HeaderUserAgent Header = "User-Agent"
|
||||||
|
|
||||||
|
// HeaderXMailer is the "X-Mailer" header field
|
||||||
|
HeaderXMailer Header = "X-Mailer"
|
||||||
|
|
||||||
// HeaderXMSMailPriority is the "X-MSMail-Priority" header field
|
// HeaderXMSMailPriority is the "X-MSMail-Priority" header field
|
||||||
HeaderXMSMailPriority Header = "X-MSMail-Priority"
|
HeaderXMSMailPriority Header = "X-MSMail-Priority"
|
||||||
|
|
||||||
|
|
13
msg.go
13
msg.go
|
@ -151,7 +151,7 @@ func (m *Msg) SetHeader(h Header, v ...string) {
|
||||||
func (m *Msg) SetAddrHeader(h AddrHeader, v ...string) error {
|
func (m *Msg) SetAddrHeader(h AddrHeader, v ...string) error {
|
||||||
var al []*mail.Address
|
var al []*mail.Address
|
||||||
for _, av := range v {
|
for _, av := range v {
|
||||||
a, err := mail.ParseAddress(m.encodeString(av))
|
a, err := mail.ParseAddress(av)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse mail address header %q: %w", av, err)
|
return fmt.Errorf("failed to parse mail address header %q: %w", av, err)
|
||||||
}
|
}
|
||||||
|
@ -337,6 +337,17 @@ func (m *Msg) SetImportance(i Importance) {
|
||||||
m.SetHeader(HeaderXMSMailPriority, i.NumString())
|
m.SetHeader(HeaderXMSMailPriority, i.NumString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetOrganization sets the provided string as Organization header for the Msg
|
||||||
|
func (m *Msg) SetOrganization(o string) {
|
||||||
|
m.SetHeader(HeaderOrganization, o)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserAgent sets the User-Agent/X-Mailer header for the Msg
|
||||||
|
func (m *Msg) SetUserAgent(a string) {
|
||||||
|
m.SetHeader(HeaderUserAgent, a)
|
||||||
|
m.SetHeader(HeaderXMailer, a)
|
||||||
|
}
|
||||||
|
|
||||||
// GetSender returns the currently set FROM address. If f is true, it will return the full
|
// GetSender returns the currently set FROM address. If f is true, it will return the full
|
||||||
// address string including the address name, if set
|
// address string including the address name, if set
|
||||||
func (m *Msg) GetSender(ff bool) (string, error) {
|
func (m *Msg) GetSender(ff bool) (string, error) {
|
||||||
|
|
Loading…
Reference in a new issue