mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
Added SetDateWithValue() as well as Reset() to Msg
This commit is contained in:
parent
bc5e6cfb95
commit
3e43819b57
1 changed files with 15 additions and 0 deletions
15
msg.go
15
msg.go
|
@ -315,6 +315,11 @@ func (m *Msg) SetDate() {
|
|||
m.SetHeader(HeaderDate, ts)
|
||||
}
|
||||
|
||||
// SetDateWithValue sets the Date genHeader field to the provided time in a valid format
|
||||
func (m *Msg) SetDateWithValue(t time.Time) {
|
||||
m.SetHeader(HeaderDate, t.Format(time.RFC1123Z))
|
||||
}
|
||||
|
||||
// SetImportance sets the Msg Importance/Priority header to given Importance
|
||||
func (m *Msg) SetImportance(i Importance) {
|
||||
if i == ImportanceNormal {
|
||||
|
@ -411,6 +416,16 @@ func (m *Msg) EmbedReader(n string, r io.Reader, o ...FileOption) {
|
|||
m.embeds = m.appendFile(m.embeds, fileFromReader(n, r), o...)
|
||||
}
|
||||
|
||||
// Reset resets all headers, body parts and attachments/embeds of the Msg
|
||||
// It leaves already set encodings, charsets, boundaries, etc. as is
|
||||
func (m *Msg) Reset() {
|
||||
m.addrHeader = make(map[AddrHeader][]*mail.Address)
|
||||
m.attachments = nil
|
||||
m.embeds = nil
|
||||
m.genHeader = make(map[Header][]string)
|
||||
m.parts = nil
|
||||
}
|
||||
|
||||
// Write writes the formated Msg into a give io.Writer
|
||||
func (m *Msg) Write(w io.Writer) (int64, error) {
|
||||
mw := &msgWriter{w: w}
|
||||
|
|
Loading…
Reference in a new issue