📧 Easy to use, yet comprehensive library for sending mails with Go https://go-mail.dev
Find a file
Winni Neessen cbba4d83d1
Add SCRAM authentication to CI workflows
This commit introduces SCRAM authentication configurations to both `codecov.yml` and `sonarqube.yml` GitHub Action workflow files. The changes include new environment variables for SCRAM host, user, and password to enhance the security and flexibility of the CI processes.
2024-10-02 15:51:56 +02:00
.github Add SCRAM authentication to CI workflows 2024-10-02 15:51:56 +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 Refactor variable names in log files 2024-02-27 11:35:37 +01:00
smtp Reset response step in AUTH LOGIN initialization 2024-10-02 13:09:55 +02:00
.cirrus.yml Update FreeBSD version in CI configuration 2024-08-16 10:25:22 +02:00
.gitignore Ignore testdata in Git 2024-03-23 16:36:01 +01:00
.golangci.toml Update GolangCI config to go 1.23 and exclude examples 2024-08-16 10:17:31 +02:00
auth.go Add comments for SMTP authentication mechanisms 2024-10-01 17:00:43 +02:00
b64linebreaker.go Refactor error handling for nil template pointers 2024-08-16 10:16:53 +02:00
b64linebreaker_test.go Rename error variables in b64linebreaker_test.go 2024-03-24 22:26:15 +01:00
client.go Reset SMTP auth when setting SMTP auth type 2024-10-01 20:44:50 +02:00
client_119.go Move mutex lock to sendSingleMsg method 2024-09-27 14:03:50 +02:00
client_120.go Move mutex lock to sendSingleMsg method 2024-09-27 14:03:50 +02:00
client_test.go Fix client connection test error handling 2024-10-02 13:10:10 +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 Update doc.go 2024-09-03 10:05:44 +02:00
doc_test.go Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
eml.go Refactor: Handle missing Content-Type as plain text 2024-08-02 15:30:46 +02:00
eml_test.go Refactor: Handle missing Content-Type as plain text 2024-08-02 15:30:46 +02:00
encoding.go Add support for US-ASCII (7bit) encoding 2024-08-01 10:54:42 +02:00
encoding_test.go Add support for US-ASCII (7bit) encoding 2024-08-01 10:54:42 +02:00
file.go Rename WithContentID to WithFileContentID 2024-06-28 13:49:21 +02:00
file_test.go Add test for WithFileContentID option 2024-06-28 13:49:34 +02:00
go.mod Update dependencies in go.mod and go.sum 2024-10-01 11:05:07 +02:00
go.sum Update dependencies in go.mod and go.sum 2024-10-01 11:05:07 +02:00
go.sum.license Add license file for go.sum 2024-10-01 15:25:51 +02:00
header.go Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-02-08 17:04:06 +01:00
header_test.go Add References header field and improve string methods 2023-10-13 15:06:54 +02:00
LICENSE Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
msg.go Remove unnecessary error handling 2024-09-20 20:39:50 +02:00
msg_nowin_test.go Add deferred TMPDIR restoration in test setup 2024-09-20 21:42:10 +02:00
msg_test.go Increase test iterations for SetMessageID randomness check 2024-09-20 20:39:30 +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 Revert after successful merge 2024-05-16 15:18:26 +02:00
msgwriter_test.go Refactor error handling for nil template pointers 2024-08-16 10:16:53 +02:00
part.go Refactor variable names for code readability 2024-02-27 11:21:28 +01:00
part_test.go Refactor variable names for code readability 2024-02-27 11:21:28 +01:00
random.go Refactor random number generation and add version-specific implementations 2024-09-20 20:30:23 +02:00
random_119.go Update build tags to support future Go versions 2024-09-27 10:52:30 +02:00
random_121.go Refactor random number generation and add version-specific implementations 2024-09-20 20:30:23 +02:00
random_122.go Refactor random number generation and add version-specific implementations 2024-09-20 20:30:23 +02:00
random_test.go Add test for zero input in randNum 2024-09-20 22:06:11 +02:00
reader.go Refactor variable names for readability in reader.go 2024-02-26 00:56:29 +01:00
reader_test.go Refactor variable names for readability in reader.go 2024-02-26 00:56:29 +01:00
README.md Simplify sponsor appreciation message 2024-10-01 16:01:58 +02:00
REUSE.toml Add REUSE.toml 2024-10-01 15:27:05 +02:00
SECURITY.md Added GPG key to SECURITY.md 2023-01-15 22:40:28 +01:00
senderror.go Add methods to retrieve message ID and message from SendError 2024-09-20 15:05:26 +02:00
senderror_test.go Refactor TestSendError_ErrorMulti formatting 2024-09-20 21:15:13 +02:00
sonar-project.properties Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
tls.go Fix typos in comments in tls.go 2024-02-24 21:46:48 +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 OpenSSF Best Practices OpenSSF Scorecard buy ma a coffee

go-mail logo

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

go-mail follows idiomatic Go style and best practice. It has a small dependency footprint by mainly relying on the Go Standard Library and the Go extended packages. It combines a lot of functionality from the standard library to give easy and convenient access to mail and SMTP related tasks.

In the early days, parts of this library (especially some parts of msgwriter.go) had been forked/ported from go-mail/mail and respectively go-gomail/gomail. Today most of the ported code has been refactored.

The smtp package of go-mail has been forked from the original Go stdlib's net/smtp package and has then been extended by the go-mail team to fit the packages needs (more SMTP Auth methods, logging, concurrency-safety, etc.).

Features

Here are some highlights of go-mail's featureset:

  • Very small dependency footprint (mainly Go Stdlib and Go extended packages)
  • 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, SCRAM-SHA-1(-PLUS), SCRAM-SHA-256(-PLUS))
  • RFC5322 compliant mail address validation
  • Support for common mail header field generation (Message-ID, Date, Bulk-Precedence, Priority, etc.)
  • Concurrency-safe 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.)
  • Output a go-mail message as EML file and parse EML file into a go-mail message

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.

Merch

Thanks to our wonderful friends at HelloTux we can offer great go-mail merchandising. All merch articles are embroidery to provide the best and most long-lasting quality possible.

If you want to support the open source community and represent your favourite Go mail library with some cool drip, check out our merch shop at: https://www.hellotux.com/go-mail.

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 created and developed by Winni Neessen, but over time a lot of amazing people contributed ot the project. Big thanks to all of them for improving the go-mail project (be it writing code, testing code, reviewing code, writing documenation or helping to translate the website):

A huge thank you also goes to Maria Letta for designing our super cool go-mail logo!

Sponsors

We sincerely thank our amazing sponsors for their generous support! Your contributions do not go unnoticed and helps keeping up the project!