From 3d5435c138ec4a8e98c1e916f50c01ee33cd26e6 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 5 Oct 2024 13:59:24 +0200 Subject: [PATCH] Update EnvelopeFromFormat documentation in msg.go Expanded the documentation for the EnvelopeFromFormat method to clarify its purpose, usage, and compliance with RFC 5322. Added details on how the envelope from address is used in SMTP communication and validation requirements. --- msg.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/msg.go b/msg.go index 7e15192..1eb90f2 100644 --- a/msg.go +++ b/msg.go @@ -398,8 +398,14 @@ func (m *Msg) EnvelopeFrom(from string) error { return m.SetAddrHeader(HeaderEnvelopeFrom, from) } -// EnvelopeFromFormat takes a name and address, formats them RFC5322 compliant and stores them as -// the envelope FROM address header field +// EnvelopeFromFormat sets the provided name and mail address as HeaderEnvelopeFrom for the Msg. +// +// The HeaderEnvelopeFrom address is generally not included in the mail body but only used by the Client for the +// communication with the SMTP server. If the Msg has no "FROM" address set in the mail body, the msgWriter will +// try to use the envelope from address, if this has been set for the Msg. The provided name and address adre +// validated according to RFC 5322 and will return an error if the validation fails. +// +// https://datatracker.ietf.org/doc/html/rfc5322#section-3.4 func (m *Msg) EnvelopeFromFormat(name, addr string) error { return m.SetAddrHeader(HeaderEnvelopeFrom, fmt.Sprintf(`"%s" <%s>`, name, addr)) }