Popularity
6.7
Growing
Activity
9.7
-
674
6
47

Description

go-mail acts as mail client for your Go programs. The Go standard library provides net/smtp which allows very low-level and basic SMTP operations. In other words, it takes the communication with the SMTP server of your hands but it leaves everything else to the user. This is where go-mail comes in. We use net/smtp ourselves (even though we forked and extended it a lot) and add a MUA-like layer on top. We handle stuff like encodings, headers, attachments, etc. for you.

So, if you write a application or library in Go and you are required to create and/or send mails, go-mail is for you! We've seperated the SMTP client from the mail message, which allows you to generate mails even if you are not planning to send them out (i. e. you need RFC compliant EML files).

Programming language: Go
License: MIT License
Tags: SMTP     Mailing     Email     Go     Package     Golang     Library     Middleware     SMTP Authentication    

wneessen/go-mail alternatives and similar packages

Based on the "Email" category.
Alternatively, view go-mail alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of wneessen/go-mail or a related project?

Add another 'Email' Package

README

<!-- SPDX-FileCopyrightText: 2022 Winni Neessen [email protected]

SPDX-License-Identifier: CC0-1.0 -->

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

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](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:

  • [X] Only Standard Library dependant
  • [X] Modern, idiomatic Go
  • [X] Sane and secure defaults
  • [X] Explicit SSL/TLS support
  • [X] Implicit StartTLS support with different policies
  • [X] Makes use of contexts for a better control flow and timeout/cancelation handling
  • [X] SMTP Auth support (LOGIN, PLAIN, CRAM-MD)
  • [X] RFC5322 compliant mail address validation
  • [X] Support for common mail header field generation (Message-ID, Date, Bulk-Precedence, Priority, etc.)
  • [X] Reusing the same SMTP connection to send multiple mails
  • [X] Support for attachments and inline embeds (from file system, io.Reader or embed.FS)
  • [X] Support for different encodings
  • [X] Middleware support for 3rd-party libraries to alter mail messages
  • [X] Support sending mails via a local sendmail command
  • [X] Support for requestng MDNs (RFC 8098) and DSNs (RFC 1891)
  • [X] DKIM signature support via go-mail-middlware
  • [X] Message object satisfies io.WriteTo and io.Reader interfaces
  • [X] Support for Go's html/template and text/template (as message body, alternative part or attachment/emebed)
  • [X] 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:


*Note that all licence references and agreements mentioned in the wneessen/go-mail README section above are relevant to that project's source code only.