diff --git a/msg.go b/msg.go index 7369b1e..5b5e002 100644 --- a/msg.go +++ b/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}