Skip to content

v0.4.1: Improved logging, attachment removing, delivery status indicaton and more *POTENTIALLY BREAKING*

Latest
Compare
Choose a tag to compare
@wneessen wneessen released this 14 Feb 15:51
· 136 commits to main since this release
56512b5

This release of go-mail brings some new features as well as some code clean up and stability improvments.

Improved logging interface (Potentially Breaking Change)

The debug logging system in go-mail has been refactored. A new custom log type Log was introduced, that includes the message direction, format and arguments. The Logger interface and the Stdlog implementation were modified to accept this new type. This change is breaking custom implementations of the Logger interface, but the new interface provides much more flexibility (#136/#141). Additionally we added support for JSON logging (#142) using the log/slog package that has been added to the stdlib in Go 1.21.

This change is breaking custom logger implementations

Removal of attachments/embeds

#147 adds support for removing all attachments/embeds/parts from a Msg. This allows to re-use a Msg and allows for replacing message parts.

The following methods can be used:

  • Msg.UnsetAllAttachments()
  • Msg.UnsetAllEmbeds()
  • Msg.UnsetAllParts()

Thanks to @leahoop for their first PR!

Reading of multiple addresses from a single comma-separated string

#155/#152 add support for three new methods that allow to read multiple recipient addresses for the TO:, CC: and BCC: fields from a single comma-separated string.

The following methods have been added:

  • Msg.ToFromString(string)
  • Msg.CcFromString(string)
  • Msg.BccFromString(string)

Thanks to @suntong for requesting this useful feature!

Delivery status indication for messages

With #167 we added support for delivery status indication of messages. This is especially helpful for bulk mailings to identify if a message was actually delivered or not. A helper method IsDelivered has been added that will return true after successful delivery of a Msg. Thanks to @mitar for requesting this useful feature!

Making use of best practice default ports and fallback ports

When using SSL or STARTTLS, so far the default port was always 25, which is against best practices as described in RFC8314, section 3.3. With #170 we've deprecated the WithSSL() and WithTLSPolicy options in favour of WithSSLPort(bool) and WithTLSPortPolicy(TLSPolicy).

  • WithSSLPort tells the Client to use a SSL/TLS connection and automatically sets the port to 465.
  • WithTLSPortPolicy tells the client to use the provided TLSPolicy and sets the correct port automatically. Port 587 is used for TLSMandatory and TLSOpportunistic. NoTLS will allways use port 25. If the connection fails with TLSOpportunistic, a plaintext connection is attempted on port 25 as a fallback.

Thanks to @muhlemmer for raising the request and providing the first part of the PR.

AUTH LOGIN extension draft

We've added support for the auth login extension draft. This effectively is a draft that expired and was deprecated in favor of the AUTH PLAIN SASL extension (#163).

Thanks to @james-d-elliott for the PR!

Code cleanup and stability

The codebase has been reviewed and a couple of potential nil pointer dereferences have been identified and fixed.
Additionally, a potential panic has been fixed in fileFromReader (#161) - thanks to @rami-dabain for their first PR!

What's Changed

  • Replace hardcoded '2' in Output with const CallDepth by @wneessen in #137
  • Fix nil pointer dereference in msgwriter due to missing error handling by @wneessen in #139
  • Update Go version to 1.21 in GitHub workflows by @wneessen in #140
  • Refactor logging for clearer messaging direction by @wneessen in #141
  • #142 Add structured JSON logger and associated tests by @wneessen in #143
  • #147 add remove attachments and embeds methods by @leahoop in #148
  • Feature/147 add method to remove any attachmentembed by @wneessen in #149
  • Add new methods and tests for handling email addresses by @wneessen in #155
  • Eleminate potential null pointer exceptions by @wneessen in #157
  • Added return error to fileFromReader by @rami-dabain in #161
  • feat(smtp): auth login extension draft support by @james-d-elliott in #163
  • Upstream sync / refine function comments to include return type GoDoc links by @wneessen in #165
  • Add delivery status indication for messages by @wneessen in #167
  • Update FreeBSD version in .cirrus.yml by @wneessen in #169
  • Add default ports and fallback behavior for SSL and TLS by @wneessen and @muhlemmer in #170
  • Add Charset support for message parts by @wneessen in #172
  • Add "X-Auto-Response-Suppress" header and update SetBulk method by @wneessen in #173
  • Update Go version in GitHub workflow files by @wneessen in #174

New Contributors

Full Changelog: v0.4.0...v0.4.1