Skip to content

v0.4.2: EML parsing, AuthTypes, SMTP/Fallback port selection and more

Compare
Choose a tag to compare
@wneessen wneessen released this 28 Jun 12:48
· 542 commits to main since this release
ffdea83

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

EML parsing

With #145 / #249 a new parsing feature has been added to go-mail which allows the user to parse generic EML files into a go-mail Msg struct. This is helpful if you have a already sent mail and want to re-use it with go-mail. Three new public methods have been added: EMLToMsgFromString, EMLToMsgFromReader and EMLToMsgFromFile, allowing the user to parse the EML from different sources.

Caveat: Even though I put lots of efforts into testing this new feature and I am certain that most cases should work without issue, emails are still a complex topic with lots of written and unwritten standards. There might be some special cases in which the parsing might be off. In this case, please raise an issue with an example of the mail, so that I can have a look.

SMTPAuthNoAuth AuthType

The SMTPAuthNoAuth AuthType has been added as convenience feature. It is equivalent to performing no authentication at all. It can be used for mail servers that do not support/require authentication. It is still advised to use the Client without the WithSMTPAuth option, instead.

Refactoring of variable names for readability

When I started go-mail, I was following the Go best practices document, choosing mostly single-character variable names. Looking at the code base size of go-mail and considering how many people work with the code base and actually contribute to the project now, I think this was the wrong decision, as it makes it hard for contributors to follow the code - especially given that I have not followed the recommendation of using more descriptive variables names for global context variables. Therefore with #182 I've refactored all variable names for better readability.

Note: The code in the smtp/ directory has been left untouched so that syncing with the upstream stdlib is not made more complicated than it has to be.

Refinement of the SMTP port selection and fallback logic

It has been pointed out in #181 that the changes to the default ports and fallback ports wasn't well thought through. With #207 this behaviour has been reworked. The clients' functions WithSSLPort, WithTLSPortPolicy, SetTLSPortPolicy, and SetSSLPort were revised to avoid overriding previously set ports. Additionally, the deprecation notes have been removed and replaced with notes on best-practice recommendations, referring the new *Port() methods.

User-Agent skipping

With #178 and option to skip the setting of the User-Agent has been added. This option is suitable for scenarios like SMTP proxies where headers are conditionally passed based on receipt. Thanks a lot to @gegorov2030 for their contribution!

What's Changed

New Contributors

Full Changelog: v0.4.1...v0.4.2