2022-06-17 15:05:54 +02:00
<!--
2023-01-15 16:12:33 +01:00
SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
2022-06-17 15:05:54 +02:00
SPDX-License-Identifier: CC0-1.0
-->
2022-10-27 14:31:14 +02:00
# go-mail - Easy to use, yet comprehensive library for sending mails with Go
2022-03-05 12:10:20 +01:00
2022-03-15 21:48:08 +01:00
[![GoDoc ](https://godoc.org/github.com/wneessen/go-mail?status.svg )](https://pkg.go.dev/github.com/wneessen/go-mail)
[![codecov ](https://codecov.io/gh/wneessen/go-mail/branch/main/graph/badge.svg?token=37KWJV03MR )](https://codecov.io/gh/wneessen/go-mail)
2022-03-15 14:54:11 +01:00
[![Go Report Card ](https://goreportcard.com/badge/github.com/wneessen/go-mail )](https://goreportcard.com/report/github.com/wneessen/go-mail)
2023-01-29 14:52:43 +01:00
[![Mentioned in Awesome Go ](https://awesome.re/mentioned-badge-flat.svg )](https://github.com/avelino/awesome-go) [![#go-mail on Discord ](https://img.shields.io/badge/Discord-%23gomail-blue.svg )](https://discord.gg/dbfQyC4s)
2022-06-17 15:29:34 +02:00
[![REUSE status ](https://api.reuse.software/badge/github.com/wneessen/go-mail )](https://api.reuse.software/info/github.com/wneessen/go-mail)
2022-03-15 14:54:11 +01:00
< a href = "https://ko-fi.com/D1D24V9IX" > < img src = "https://uploads-ssl.webflow.com/5c14e387dab576fe667689cf/5cbed8a4ae2b88347c06c923_BuyMeACoffee_blue.png" height = "20" alt = "buy ma a coffee" > < / a >
2022-03-05 12:10:20 +01:00
2022-07-11 10:21:09 +02:00
< p align = "center" > < img src = "./assets/gopher2.svg" width = "250" alt = "go-mail logo" / > < / p >
2022-07-08 16:04:04 +02:00
2022-03-10 10:53:38 +01:00
The main idea of this library was to provide a simple interface to sending mails for
2022-03-14 10:57:55 +01:00
my [JS-Mailer ](https://github.com/wneessen/js-mailer ) project. It quickly evolved into a full-fledged mail library.
2022-03-05 12:10:20 +01:00
2022-03-14 10:57:55 +01:00
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.
2022-03-10 16:19:51 +01:00
2022-03-14 10:57:55 +01:00
Parts of this library (especially some parts of [msgwriter.go ](msgwriter.go )) have been forked/ported from the
[go-mail/mail ](https://github.com/go-mail/mail ) respectively [go-gomail/gomail ](https://github.com/go-gomail/gomail )
2022-03-14 10:33:15 +01:00
which both seems to not be maintained anymore.
2023-01-15 16:12:33 +01:00
The smtp package of go-mail is forked from the original Go stdlib's `net/smtp` and then extended by the go-mail
team.
2022-03-10 16:19:51 +01:00
## Features
2022-03-14 10:57:55 +01:00
2022-03-10 16:19:51 +01:00
Some of the features of this library:
2022-03-14 10:57:55 +01:00
2022-03-10 16:19:51 +01:00
* [X] Only Standard Library dependant
2022-03-12 15:19:32 +01:00
* [X] Modern, idiomatic Go
2022-03-10 16:56:41 +01:00
* [X] Sane and secure defaults
2022-03-14 10:57:01 +01:00
* [X] Explicit SSL/TLS support
* [X] Implicit StartTLS support with different policies
2022-03-10 16:19:51 +01:00
* [X] Makes use of contexts for a better control flow and timeout/cancelation handling
2022-03-14 10:35:23 +01:00
* [X] SMTP Auth support (LOGIN, PLAIN, CRAM-MD)
2022-03-10 16:19:51 +01:00
* [X] RFC5322 compliant mail address validation
2022-03-14 10:57:01 +01:00
* [X] Support for common mail header field generation (Message-ID, Date, Bulk-Precedence, Priority, etc.)
2022-03-10 16:19:51 +01:00
* [X] Reusing the same SMTP connection to send multiple mails
2022-07-07 10:58:52 +02:00
* [X] Support for attachments and inline embeds (from file system, `io.Reader` or `embed.FS` )
2022-05-28 10:58:19 +02:00
* [X] Support for different encodings
2022-10-02 13:03:51 +02:00
* [X] Middleware support for 3rd-party libraries to alter mail messages
2022-05-24 16:33:41 +02:00
* [X] Support sending mails via a local sendmail command
2022-09-11 21:07:15 +02:00
* [X] Support for requestng MDNs (RFC 8098) and DSNs (RFC 1891)
2022-10-26 20:06:17 +02:00
* [X] DKIM signature support via [go-mail-middlware ](https://github.com/wneessen/go-mail-middleware )
2022-05-28 10:58:19 +02:00
* [X] Message object satisfies `io.WriteTo` and `io.Reader` interfaces
2022-06-03 10:42:56 +02:00
* [X] Support for Go's `html/template` and `text/template` (as message body, alternative part or attachment/emebed)
2022-06-09 10:24:57 +02:00
* [X] Output to file support which allows storing mail messages as e. g. `.eml` files to disk to open them in a MUA
2023-01-15 16:12:33 +01:00
* [X] Debug logging of SMTP traffic
* [X] Custom error types for delivery errors
2022-03-10 10:53:38 +01:00
2022-03-14 10:57:55 +01:00
go-mail works like a programatic email client and provides lots of methods and functionalities you would consider
standard in a MUA.
2022-03-14 10:57:01 +01:00
2022-10-27 14:31:14 +02:00
## 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 ](https://go-mail.dev )
2022-09-22 16:54:38 +02:00
## Support
2023-01-29 14:52:43 +01:00
We have a support and general discussion channel on Discord. Find us at: [#go-mail ](https://discord.gg/dbfQyC4s )
2022-10-02 13:03:51 +02:00
## 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 ](https://github.com/wneessen/go-mail-middleware ).
2022-03-12 15:19:32 +01:00
## Examples
2022-03-14 10:57:55 +01:00
2022-10-27 14:31:14 +02:00
We provide example code in both our GoDocs as well as on our official Website (see [Documentation ](#documentation )). For a quick start into go-mail
check out our [Getting started ](https://go-mail.dev/getting-started/introduction/ ) guide.
2022-05-28 11:14:26 +02:00
2023-01-15 16:12:33 +01:00
## Authors/Contributors
go-mail was initially authored and developed by [Winni Neessen ](https://github.com/wneessen/ ).
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):
2022-09-23 11:19:35 +02:00
* [Dhia Gharsallaoui ](https://github.com/dhia-gharsallaoui )
2022-05-28 11:14:26 +02:00
* [inliquid ](https://github.com/inliquid )
2023-01-15 16:12:33 +01:00
* [iwittkau ](https://github.com/iwittkau )
* [James Elliott ](https://github.com/james-d-elliott )
2022-07-08 16:04:04 +02:00
* [Maria Letta ](https://github.com/MariaLetta ) (designed the go-mail logo)