📧 Easy to use, yet comprehensive library for sending mails with Go https://go-mail.dev
Find a file
2022-03-10 10:53:38 +01:00
.idea Implemented SMTP AUTH 2022-03-10 10:53:38 +01:00
cmd Implemented SMTP AUTH 2022-03-10 10:53:38 +01:00
.cirrus.yml Enable CirrusCI 2022-03-05 12:13:46 +01:00
.gitignore Initial commit 2022-03-05 12:03:35 +01:00
auth.go Implemented SMTP AUTH 2022-03-10 10:53:38 +01:00
client.go Implemented SMTP AUTH 2022-03-10 10:53:38 +01:00
client_test.go More progress... calling it a day. 2022-03-09 16:52:23 +01:00
doc.go Typo fix 2022-03-09 17:30:35 +01:00
encoding.go More progress... calling it a day. 2022-03-09 16:52:23 +01:00
go.mod Initial checkin 2022-03-05 12:10:20 +01:00
go.sum Initial checkin 2022-03-05 12:10:20 +01:00
header.go More progress... calling it a day. 2022-03-09 16:52:23 +01:00
LICENSE Initial commit 2022-03-05 12:03:35 +01:00
mailmsg.go Make GoLint happy 2022-03-09 17:05:38 +01:00
README.md Implemented SMTP AUTH 2022-03-10 10:53:38 +01:00
tls.go Slow progress 2022-03-07 16:24:49 +01:00

go-mail - Simple and easy way to send mails in Go

Go Report Card Build Status buy ma a coffee

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.

This library is "WIP" an should not be considered "production ready", yet.

go-mail follows idiomatic Go style and best practice.

Example

package main

import (
	"context"
	"fmt"
	"github.com/wneessen/go-mail"
	"os"
	"time"
)

func main() {
	c, err := mail.NewClient("mail.example.com", mail.WithTimeout(time.Millisecond*500),
		mail.WithTLSPolicy(mail.TLSMandatory), mail.WithSMTPAuth(mail.SMTPAuthDigestMD5),
		mail.WithUsername("tester@example.com"), mail.WithPassword("secureP4ssW0rd!"))
	if err != nil {
		fmt.Printf("failed to create new client: %s\n", err)
		os.Exit(1)
	}

	ctx, cfn := context.WithCancel(context.Background())
	defer cfn()

	if err := c.DialWithContext(ctx); err != nil {
		fmt.Printf("failed to dial: %s\n", err)
		os.Exit(1)
	}
	if err := c.Send(); err != nil {
		fmt.Printf("failed to send: %s\n", err)
		os.Exit(1)
    }
}