📧 Easy to use, yet comprehensive library for sending mails with Go https://go-mail.dev
Find a file
Winni Neessen 39080a8a05
#136: Add error handling to message writing process
In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously
2023-08-08 10:54:38 +02:00
.github Update golangci-lint to Go 1.20 2023-02-02 19:10:16 +01:00
.idea #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
.reuse #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
assets Switch logo to CC-BY-ND-4.0 license 2022-07-11 13:23:50 +02:00
LICENSES Fix license SPDX headers for forked net/smtp code 2023-01-10 10:09:45 +01:00
log #136: Refactor logging for clearer messaging direction 2023-08-02 11:43:45 +02:00
smtp #136: Refactor logging for clearer messaging direction 2023-08-02 11:43:45 +02:00
.cirrus.yml CI FreeBSD: use the latest 12.x and 13.x versions 2023-05-29 18:22:58 +02:00
.gitignore Preparation for the v0.4.0 release: 2023-05-31 09:34:45 +02:00
.golangci.toml Update golangci-lint to Go 1.20 2023-02-02 19:10:16 +01:00
auth.go OAuth2: remove variants 2023-05-29 18:19:01 +02:00
b64linebreaker.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
b64linebreaker_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
client.go OAuth2: remove variants 2023-05-29 18:19:01 +02:00
client_119.go Refactor DSN handling from client.go to smtp.go 2023-01-18 10:30:06 +01:00
client_120.go Refactor DSN handling from client.go to smtp.go 2023-01-18 10:30:06 +01:00
client_test.go oauth2: add more test cases 2023-06-04 10:47:19 +02:00
CODE_OF_CONDUCT.md #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
codecov.yml Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
CONTRIBUTING.md Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
doc.go Preparation for the v0.4.0 release: 2023-05-31 09:34:45 +02:00
doc_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
encoding.go Adding PGPType to Msg as preparation to support PGP/MIME in go-mail-middleware 2023-01-31 18:35:48 +01:00
encoding_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
file.go Adding PGPType to Msg as preparation to support PGP/MIME in go-mail-middleware 2023-01-31 18:35:48 +01:00
file_test.go More test coverage for the added functionalities 2023-02-13 11:27:25 +01:00
go.mod Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
go.sum Forgot to update go.mod/.sum 2022-03-13 17:25:57 +01:00
header.go Adding PGPType to Msg as preparation to support PGP/MIME in go-mail-middleware 2023-01-31 18:35:48 +01:00
header_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
LICENSE Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
msg.go Preparation for the v0.4.0 release: 2023-05-31 09:34:45 +02:00
msg_nowin_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
msg_test.go Preparation for the v0.4.0 release: 2023-05-31 09:34:45 +02:00
msg_totmpfile.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
msg_totmpfile_116.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
msgwriter.go #136: Add error handling to message writing process 2023-08-08 10:54:38 +02:00
msgwriter_test.go Test coverage for the added functionalities 2023-02-13 11:09:19 +01:00
part.go Adding PGPType to Msg as preparation to support PGP/MIME in go-mail-middleware 2023-01-31 18:35:48 +01:00
part_test.go Test coverage for the added functionalities 2023-02-13 11:09:19 +01:00
random.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
random_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
reader.go Preparation for the v0.4.0 release: 2023-05-31 09:34:45 +02:00
reader_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
README.md Preparation for the v0.4.0 release: 2023-05-31 09:40:51 +02:00
SECURITY.md Added GPG key to SECURITY.md 2023-01-15 22:40:28 +01:00
senderror.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
senderror_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
sonar-project.properties Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
tls.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
tls_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00

go-mail - Easy to use, yet comprehensive library for sending mails with Go

GoDoc codecov Go Report Card Mentioned in Awesome Go #go-mail on Discord REUSE status buy ma a coffee

go-mail logo

The main idea of this library was to provide a simple interface to sending mails for my JS-Mailer project. It quickly evolved into a full-fledged mail library.

go-mail follows idiomatic Go style and best practice. It's only dependency is the Go Standard Library. It combines a lot of functionality from the standard library to give easy and convenient access to mail and SMTP related tasks.

Parts of this library (especially some parts of msgwriter.go) have been forked/ported from the go-mail/mail respectively go-gomail/gomail which both seems to not be maintained anymore.

The smtp package of go-mail is forked from the original Go stdlib's net/smtp and then extended by the go-mail team.

Features

Some of the features of this library:

  • Only Standard Library dependant
  • Modern, idiomatic Go
  • Sane and secure defaults
  • Explicit SSL/TLS support
  • Implicit StartTLS support with different policies
  • Makes use of contexts for a better control flow and timeout/cancelation handling
  • SMTP Auth support (LOGIN, PLAIN, CRAM-MD, XOAUTH2)
  • RFC5322 compliant mail address validation
  • Support for common mail header field generation (Message-ID, Date, Bulk-Precedence, Priority, etc.)
  • Reusing the same SMTP connection to send multiple mails
  • Support for attachments and inline embeds (from file system, io.Reader or embed.FS)
  • Support for different encodings
  • Middleware support for 3rd-party libraries to alter mail messages
  • Support sending mails via a local sendmail command
  • Support for requestng MDNs (RFC 8098) and DSNs (RFC 1891)
  • DKIM signature support via go-mail-middlware
  • Message object satisfies io.WriteTo and io.Reader interfaces
  • Support for Go's html/template and text/template (as message body, alternative part or attachment/emebed)
  • Output to file support which allows storing mail messages as e. g. .eml files to disk to open them in a MUA
  • Debug logging of SMTP traffic
  • Custom error types for delivery errors
  • Custom dial-context functions for more control over the connection (proxing, DNS hooking, etc.)

go-mail works like a programatic email client and provides lots of methods and functionalities you would consider standard in a MUA.

Documentation

We aim for good GoDoc documenation in our library which gives you a full API reference. We also provide a more in-depth documentation website at go-mail.dev

Compatibility

Go is growing fast and providing great features with every new release. While we'd love to adopt the latest Go features into our code, we realize that not everybody using this package can run the latest Go versions. Therefore we try to implement alternative solutions for Go versions that do not support these features. Yet, the work needed to maintain the separate versions is not to be underestimated. For that reason, we might retire that code at some point. We guarantee that go-mail will always support the last four releases of Go. With two Go releases per year, this gives the user a timeframe of two years to update to the next or even the latest version of Go.

Support

We have a support and general discussion channel on Discord. Find us at: #go-mail

Middleware

The goal of go-mail is to keep it free from 3rd party dependencies and only focus on things a mail library should fulfill. Yet, since version v0.2.8 we've added support for middleware on the Msg object, allowing 3rd parties to alter a given mail message to their needs without relying on go-mail to support their specific need.

To get our users started with message middleware, we've created a collection of useful middlewares. It can be found in a seperate repository: go-mail-middlware.

Examples

We provide example code in both our GoDocs as well as on our official Website (see Documentation). For a quick start into go-mail check out our Getting started guide.

Authors/Contributors

go-mail was initially authored and developed by Winni Neessen.

Big thanks to the following people, for contributing to the go-mail project (either in form of code or by reviewing code, writing documenation or helping to translate the website):