Gomailer provides a simple email interface to integrate third party email services.
MIT License
This package provides a simple email interface to integrate third party email services. You can integrate popular email services and switch easily.
Install the package using
$ go get github.com/thedevsaddam/gomailer
To use the package import it in your *.go
code
import "github.com/thedevsaddam/gomailer"
package main
import (
"log"
mailer "github.com/thedevsaddam/gomailer"
)
func main() {
c := mailer.Configs{
Domain: "Your domain here",
APIKey: "Your key here",
}
m, err := mailer.New(mailer.MAILGUN, c)
checkError(err)
m.From("John Doe", "[email protected]")
m.To("Jane Doe", "[email protected]")
m.Cc("Tom", "[email protected]")
m.Bcc("Jerry", "[email protected]")
m.ReplyTo("Salman", "[email protected]")
m.Subject("mailgun: Urgent email about tom & jerry")
// m.BodyText("This is a test text email")
m.BodyHTML("<html>Inline image here: <img src='cid:a.jpg'></html>")
m.AttachmentFile("a.jpg")
checkError(err)
err = m.Send()
checkError(err)
}
func checkError(err error) {
if err != nil {
log.Println(err)
}
}
You can chain methods easily
m, err := mailer.New(mailer.MAILGUN, c)
m.To("name", "email").Cc("name", "email").Bcc("name", "email").Bcc("name", "email").Subject("Your subject").BodyText("simple message here").AttachmentFile("some/file.zip").Send()
This package is under development, need to write tests, unimplemented services. Use now at your own risk.
Your suggestions will be more than appreciated. Read the contribution guide here
The gomailer is an open-source software licensed under the MIT License.