mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
Add an option to skip adding a User-Agent
This commit is contained in:
parent
68e6284e4e
commit
a24906d185
1 changed files with 13 additions and 0 deletions
13
msg.go
13
msg.go
|
@ -117,6 +117,9 @@ type Msg struct {
|
|||
|
||||
// sendError holds the SendError in case a Msg could not be delivered during the Client.Send operation
|
||||
sendError error
|
||||
|
||||
// noDefaultUserAgent indicates whether the default User Agent will be excluded for the Msg when it's sent.
|
||||
noDefaultUserAgent bool
|
||||
}
|
||||
|
||||
// SendmailPath is the default system path to the sendmail binary
|
||||
|
@ -192,6 +195,13 @@ func WithPGPType(t PGPType) MsgOption {
|
|||
}
|
||||
}
|
||||
|
||||
// WithNoDefaultUserAgent configures the Msg to not use the default User Agent
|
||||
func WithNoDefaultUserAgent() MsgOption {
|
||||
return func(m *Msg) {
|
||||
m.noDefaultUserAgent = true
|
||||
}
|
||||
}
|
||||
|
||||
// SetCharset sets the encoding charset of the Msg
|
||||
func (m *Msg) SetCharset(c Charset) {
|
||||
m.charset = c
|
||||
|
@ -1166,6 +1176,9 @@ func (m *Msg) setEncoder() {
|
|||
// checkUserAgent checks if a useragent/x-mailer is set and if not will set a default
|
||||
// version string
|
||||
func (m *Msg) checkUserAgent() {
|
||||
if m.noDefaultUserAgent {
|
||||
return
|
||||
}
|
||||
_, uaok := m.genHeader[HeaderUserAgent]
|
||||
_, xmok := m.genHeader[HeaderXMailer]
|
||||
if !uaok && !xmok {
|
||||
|
|
Loading…
Reference in a new issue