Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Welcome to the go-mail documentation

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

go-mail logo

go-mail is an easy to use Go library for formating and sending mails. It uses idiomatic Go style and follows best practice with sane defaults. The library only dependends on the Go Standard Library.

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

Feature highlights

Standard Library dependant

go-mail does not require any third-party modules and only runs on the Go standard library

Modern, idiomatic Go

We are using modern and idiotmatic Go standards with this library and follow state-of-the-art best practices with sane defaults

Full TLS support

go-mail supports implicit STARTTLS with different policies as well as explicit SSL/TLS for connections to sending mail servers


We make use of Go contexts for better control flow and timeout/cancelation handling

SMTP Authentication

Support for three common SMTP authentication mechanisms (LOGIN, PLAIN, CRAM-MD5) as well as custom authentications.

Mail address validation

go-mail follows RFC5322 and validates the provided mail addresses

Common mail header support

go-mail brings generators for lots of common mail headers (Message-ID, Date, Bulk-Precedence, Priority, etc.)

Connection reusing

You can send mulitple mails over the same SMTP connection


Full support for attachments and inline embeds from different sources (local file system, io.Reader or embed.FS)

Encodings and content types

go-mail supports different encondings and content types out of the box


Middleware support for 3rd-party libraries to alter mail message to their need

Sendmail and file storage

Support for sending mail messages through a local sendmail installation as well as output to local files (e. g. as .eml files to disk to open them in a MUA)

MDNs and DSNs

go-mail brings support for requestng MDNs (RFC 8098) and DSNs (RFC 1891)

Template support

Support for Go’s html/template and text/template (as message body, alternative part or attachment/emebed)

DKIM support

DKIM signature support via the go-mail-middlware/dkim middleware

Debug logging

Support for the SMTP client to log any SMTP communication to STDERR for debug purposes

Custom delivery errors

With the SendError type the user is able to get detailed information about delivery errors including if the error is of temporary nature or not


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