📧 Easy to use, yet comprehensive library for sending mails with Go https://go-mail.dev
Find a file
2023-01-01 14:25:44 +01:00
.github Update sonarqube.yml 2022-10-18 17:36:13 +02: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
auth Make golangci-lint gofumpt happy 2022-10-17 18:12:18 +02:00
LICENSES Switch logo to CC-BY-ND-4.0 license 2022-07-11 13:23:50 +02:00
.cirrus.yml #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
.gitignore Updated .gitignore 2022-10-18 15:39:55 +02:00
.golangci.toml Update golangci-lint config 2022-10-17 18:34:05 +02:00
auth.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
b64linebreaker.go #42: Return error in b64linebreaker.go when no out is set 2022-09-08 15:43:14 +02:00
b64linebreaker_test.go #42: Better test coverage for b64linebreaker.go. Also we return errors now 2022-09-08 11:47:11 +02:00
client.go Merge pull request #88 from james-d-elliott/feat-without-noop 2022-12-26 16:49:38 +01:00
client_119.go Proposal change for #90 2023-01-01 14:20:13 +01:00
client_120.go Proposal change for #90 2023-01-01 14:20:13 +01:00
client_test.go Proposal change for #90 2023-01-01 14:20:13 +01:00
CODE_OF_CONDUCT.md #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
codecov.yml #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
CONTRIBUTING.md #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
doc.go Update doc.go 2022-12-10 13:53:07 +01:00
doc_test.go Make golangci-lint gofumpt happy 2022-10-17 18:13:28 +02:00
encoding.go Make golangci-lint gofumpt happy 2022-10-17 18:13:00 +02:00
encoding_test.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
file.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
file_test.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
go.mod #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
go.sum Forgot to update go.mod/.sum 2022-03-13 17:25:57 +01:00
header.go Added support for requesting MDNs as described in RFC 8098 2022-09-09 11:35:45 +02:00
header_test.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
LICENSE Initial commit 2022-03-05 12:03:35 +01:00
msg.go Make golangci-lint happy by using errors.As instead of using type assertion on error (which can fail on wrapped errors) 2023-01-01 14:25:00 +01:00
msg_nowin_test.go #42: Add test for Msg.WriteToSendmail 2022-09-08 15:08:17 +02:00
msg_test.go Merge pull request #83 from wneessen/feature/80_add-getaddrheader 2022-11-19 11:31:28 +01:00
msg_totmpfile.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
msg_totmpfile_116.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
msgwriter.go #81: Fix error handling in body writer 2022-11-19 09:55:38 +01:00
msgwriter_test.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
part.go Closes #60. Added final test coverage and an additional SetContent method 2022-10-11 19:27:54 +02:00
part_test.go Closes #60. Added final test coverage and an additional SetContent method 2022-10-11 19:27:54 +02:00
random.go Replace math/rand with crypto/rand 2022-10-26 14:05:25 +02:00
random_test.go Test for random.go added 2022-10-26 14:21:00 +02:00
reader.go Finalized the Reader type and removed the broken Read() method 2022-10-20 18:26:51 +02:00
reader_test.go Fix REUSE header 2022-10-20 18:33:18 +02:00
README.md Update README.md 2022-10-27 14:31:14 +02:00
SECURITY.md #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
senderror.go Make golangci-lint happy by using errors.As instead of using type assertion on error (which can fail on wrapped errors) 2023-01-01 14:25:00 +01:00
senderror_test.go Add missing REUSE header in senderror_test.go 2023-01-01 14:25:44 +01:00
sonar-project.properties Update sonar-project.properties 2022-10-18 17:37:34 +02:00
tls.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02:00
tls_test.go #24: Add SPDX license IDs for REUSE compliance 2022-06-17 15:05:54 +02: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.

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)
  • 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

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

Support

We have a support and general discussion channel on the Gophers Discord server. 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.

Contributors

Thanks to the following people for contributing to the go-mail project: