Skip to content

Commit

Permalink
Update EnvelopeFromFormat documentation in msg.go
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wneessen committed Oct 5, 2024
1 parent 1dcdad9 commit 3d5435c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 3d5435c

Please sign in to comment.