libsmtp

Simple additions to Go's net/smtp package

BSD-4-CLAUSE License

Stars
39

libsmtp is an add-on package for Go's net/smtp package.

The original net/smtp is rightfully incomplete, Go intends the standard library to remain small, nimble and manageable. The SMTP specification is none of those things.

libsmtp provides support for attachments and filling the client-fields in e-mail messages.


package main

import (
	"fmt"
	"github.com/AeroNotix/libsmtp"
	"net/smtp"
	"io"
	"os"
)

func main() {
	auth := smtp.PlainAuth(
		"",
		"your_email",
		"password",
		"smtp.domain.com",
	)
	f, _ := os.Open("/path/to/file/")
	fmt.Println(
		libsmtp.SendMailWithAttachments(
			"smtp.domain.com:port",
			&auth,
			"[email protected]",
			"Y u no talk?",
			[]string{"[email protected]"},
			[]byte("Message!"),
			map[string]io.Reader{
				"filename": f,
			},
		),
	)

}