Releases: wneessen/go-mail
v0.2.7: MDNs and DSNs
This release adds support for requesting MDNs (RFC 8098) and DSNs (RFC 1891) to be delivered for outgoing mail messages. We've also added more test coverage.
MDNs
MDNs (Message Disposition Notification) allows you to request a - what is often referred to as - "read receipt". This is implemented via a message header and it's up the the recipients MUA to send out this notification to the sender.
Code example:
func main() {
// [...]
m := mail.NewMsg()
if err := m.FromFormat("Max Tester", "[email protected]"); err != nil {
panic(err)
}
if err := m.To("[email protected]"); err != nil {
panic(err)
}
m.Subject("This is an example")
if err := m.RequestMDNTo("[email protected]"); err != nil {
fmt.Printf("failed to set MDN request header: %s", err)
}
// [...]
}
For MDNs we implement the same methods as for the To
methods:
RequestMDNTo
RequestMDNToFormat
RequestMDNAddTo
RequestMDNAddToFormat
DSNs
DSNs (Delivery Status Notification) are an extension to the SMTP protocol and need to be supported by the sending server. The RFC for DSNs defines different parameters of which we've implemented the once which we think make most sense for go-mail:
- The
RET
extension for theMAIL FROM
command, to let the user specify if a DSN should contain the full mail (FULL
) or only headers (HDRS
) of the sent mail. - The
NOTIFY
extension that allows the user to request a DSN for the different types of allowed situations:NEVER
,SUCCESS
,FAILURE
andDELAY
ENVID
and ORCPT
are currently not supported but might follow in a later relaese (please open an issue if you see usefulness in this).
Since DSNs are part of the SMTP protocol, these need to be enabled on the Client
. We've added 3 ways to do so:
WithDSN
: Which enables DSNs, sets theFULL
Mail From Return Option and theSUCCESS
andFAILURE
Recipient Notify OptionsWithDSNMailReturnType
: which enables DSNs and allows the user to specify which type of Mail From Return Option is wantedWithDSNRcptNotifyType
: which enables DSNs and allows the user to specify which types of Recipient Notify Options are wanted
Code example:
func main() {
// [...]
cl, err := mail.NewClient("relay.example.net",
mail.WithDSNMailReturnType(mail.DSNMailReturnFull),
mail.WithDSNRcptNotifyType(mail.DSNRcptNotifyFailure, mail.DSNRcptNotifyDelay, mail.DSNRcptNotifySuccess))
if err != nil {
fmt.Printf("failed to create new client: %s\n", err)
os.Exit(1)
}
// [...]
}
Noteworthy changes
v0.2.6: fix issue with Base64 encoded mail parts
#37 brought up an issue, in which some mail servers would not accept mails sent via go-mail services. They returned 550 Maximum line length exceeded (see RFC 5322 2.1.1)
errors. It turns out, that Go's encoding/base64 does not add line breaks when encoding data. This release adds a Base64LineBreaker
struct, which satisfies the io.WriteCloser interface and makes sure that mail parts, that are base64 encoded, are properly broken up at 76 chars.
Noteworthy changes
- c6fe75f introduces the
Base64LineBreaker
Thanks to @chriselkins for bringing this to my attention!
v0.2.5: embed.FS support
This release adds support for embedding/attaching files directly from embed.FS
. We've added two new methods:
Msg.EmbedFromEmbedFS()
which will allow you to embed a file from a givenembed.FS
directly into the mail messageMsg.AttachFromEmbedFS()
which will allow you to attach a file from a givenembed.FS
directly into the mail message
Noteworthy changes
- #29 implements the embed.FS changes
v0.2.4: Dedicated envelope from address
This release adds support for setting a different envelope from address than the actual from address in the mail body. We've added two methods:
Msg.EnvelopeFrom()
which will set the envelope from address analogous to theMsg.From()
methodMsg.EnvelopeFromFormat()
which will set a formated envelope from address analogous to theMsg.FromFormat()
method
Msg.GetSender()
which is used by the Client
has been adjusted to return the envelope from in favour of the mail body from address. If no envelope from is set, it will still use the normal mail body from address as envelope from. The MsgWriter
has been adjusted accordingly to only use the envelope from address if the mail body from address is not set.
Noteworthy changes
- #21 implements the envelope from changes
v0.2.3: File output support
This release adds support for writing mail messages directly into a file. We've added two methods:
Msg.WriteToTempFile()
which will automatically generated a.eml
file localted in the OS' temporary directoryMsg.WriteToFile()
which takes a filename as argument and stores the output of the mail message into that file
If the message output is stored with a .eml
file extension, the mail is usually detected as such and can be directly opened with the OS' MUA. This has been tested with Mail.App, Thunderbird and Outlook.
Noteworthy changes
v0.2.2: Template support
This release adds support for html/template
and text/template
to go-mail. You are now able to utilize several methods to write the message body, add alternative body parts, add attachments or add embeds using Go's template engine.
Noteworthy changes
v0.2.1: io.Reader interface
This release adds a Msg.Read()
method to go-mail, so that it satisfies the io.Reader
interface which allows us to e. g. use io.Copy
to dump a message to a io.Writer
Changes
- dd02ac2 Add
Msg.Read()
v0.2.0: Fixes in WriteTo() and WriteToSendmail()
This release fixes two bugs in the msg.WriteTo()
and the msg.WriteToSendmail()
methods
Changes
- 4fe503d Fixes hanging reads in the
msg.WriteToSendmail()
method (see #7) Thanks to @inliquid for the PR - ebef1fe Fixes a bug in
msg.WriteTo()
that would not output the message body on subsequent calls tomsg.WriteTo()
after the first invocation ofmsg.WriteTo()
(see #8). Thanks @inliquid for the bug report
v0.1.9: Satisfy io.WriteTo interface and fix in WriteToSendmail*
v0.1.8: First release
Changelog
- 6a446bd fixes an issue in the SMTP AUTH module for "LOGIN" in case the server responds with an "Authentcation successful" response, which isn't really expected
- 030eba8 Sets default headers if they are not set, also the generic headers are now sorted before writing
Since we finally reached a test coverage of 85%, this will be the first non pre-release.