Winni Neessen
78df991399
Did a complete overhaul of the senderror.go. - the list of `errors.New()` has been replaced with constant itoa error reasons as `SendErrReason`. Instead, the `Error()` method now reports the corresponding error message based on the reason. - The `SendError` received a `Is()` method so that we can use `errors.Is()` for very specific error checking. I.e. we can check for `&SendErrors{Reason: ErrSMTPMailFrom, isTemp: true}`. This provides much more flexibility in the error checking capabilities - A `isTemp` field has been added to the `SendError` type, indicating whether the received error is temporary and can be retried or not. Accordingly, the `*Msg` now has a `SendErrorIsTemp()` method indicating the same. The decision is based on the first 3 characters returned from the SMTP server. If the error code is within the 4xx range, the error is seen as temporary - A test for the SendError type has been added |
||
---|---|---|
.github | ||
.idea | ||
.reuse | ||
assets | ||
auth | ||
LICENSES | ||
.cirrus.yml | ||
.gitignore | ||
.golangci.toml | ||
auth.go | ||
b64linebreaker.go | ||
b64linebreaker_test.go | ||
client.go | ||
client_119.go | ||
client_120.go | ||
client_test.go | ||
CODE_OF_CONDUCT.md | ||
codecov.yml | ||
CONTRIBUTING.md | ||
doc.go | ||
doc_test.go | ||
encoding.go | ||
encoding_test.go | ||
file.go | ||
file_test.go | ||
go.mod | ||
go.sum | ||
header.go | ||
header_test.go | ||
LICENSE | ||
msg.go | ||
msg_nowin_test.go | ||
msg_test.go | ||
msg_totmpfile.go | ||
msg_totmpfile_116.go | ||
msgwriter.go | ||
msgwriter_test.go | ||
part.go | ||
part_test.go | ||
random.go | ||
random_test.go | ||
reader.go | ||
reader_test.go | ||
README.md | ||
SECURITY.md | ||
senderror.go | ||
senderror_test.go | ||
sonar-project.properties | ||
tls.go | ||
tls_test.go |
go-mail - Easy to use, yet comprehensive library for sending mails with Go
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
orembed.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
andio.Reader
interfaces - Support for Go's
html/template
andtext/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:
- Dhia Gharsallaoui
- inliquid
- Maria Letta (designed the go-mail logo)