Skip to content

Wrapper of SDKs(SendGrid, MailGun, Gmail, AWS SES, SSL SMTP) Mailer

License

Notifications You must be signed in to change notification settings

thiagozs/mailer-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wrapper of SDKs(SendGrid, MailGun, Gmail, AWS SES, SSL SMTP) Mailer

Codeship Status for thiagozs/sendmail-poc-go Go Report Card

  • Go 1.9
  • SDK Sendgrid
  • SDK Mailgun
  • SDK Gmail
  • SDK AWS SES
  • Simple SSL SMTP
  • Glide package manager
  • Linux

Just get the package.

go get -v github.com/thiagozs/mailer-go

To run the study just execute the env.sh file to setup the path and exports.

$. ./env.sh

In your {your-project}/src run the glide to download the dependencies of project.

.../src$ glide up

On root of project, create the file .env with the contents:

SENDGRID_API_KEY=...
MAILGUN_DOMAIN=...
MAILGUN_API_KEY=...
MAILGUN_PUB_KEY=...
GMAIL_LOGIN=...
GMAIL_PASSWD=...
EMAILFROM=...
EMAILFROMNAME=...
EMAILTO=...
EMAILTONAME=...
SMTPSSL_USER=...
SMTPSSL_PASSWD=...
SMTPSSL_SERVER=...
SMTPSSL_PORT=...

The project is open for any upgrade / commit, submit your proof of concept (POC).

Simple example of code implementation.

package main

import (
	"fmt"
	mailer "github.com/thiagozs/mailer-go"
	"time"
)

func main() {

	//Sendgrid Instance
	sg := mailer.NewMailerSendGrid(os.Getenv("SENDGRID_API_KEY"))
	sg.Delay = time.Second * 5

	//Mailgun Instance
	mg := mailer.NewMailerMailGun(os.Getenv("MAILGUN_DOMAIN"),
		os.Getenv("MAILGUN_API_KEY"),
		os.Getenv("MAILGUN_PUB_KEY"))
	mg.Delay = time.Second * 5

	//Gmail Instance
	gm := mailer.NewMailerGmail(os.Getenv("GMAIL_LOGIN"),
		os.Getenv("GMAIL_PASSWD"))
	gm.Delay = time.Second * 5

	// --------------

	// Sendgrid configs
	sg.ConfigEmail = mailer.ConfigEmailSendgrid{
		ContentHTML:      "<b>Test</b>",
		ContentPlainText: "Test",
		EmailFromName:    "Thiago Zilli",
		EmailFrom:        "yourmail@host.com",
		EmailToName:      "Client Name here",
		EmailTo:          "emailofclient@host.com",
		Subject:          "Test email",
	}

	// Mailgun configs
	mg.ConfigEmail = mailer.ConfigEmailMailGun{
		ContentPlainText: "Test",
		EmailFrom:        "yourmail@host.com",
		EmailTo:          "emailofclient@host.com",
		Subject:          "Test email",
	}

	// Gmail Configs
	gm.ConfigEmail = mailer.ConfigEmailGmail{
		ContentHTML: "<b>Test with Gmail</b>",
		EmailFrom:   "yourmail@host.com",
		EmailTo:     "emailofclient@host.com",
		Subject:     "Test email",
	}

	// --------------

	// Send email by Sendgrid
	if err := sg.SendMail(); err != nil {
		fmt.Printf("Sendgrid Error: %s\n", err.Error())
	}

	// Send email by Mailgun
	if err := mg.SendMail(); err != nil {
		fmt.Printf("Mailgun Error: %s\n", err.Error())
	}

	// Send email by Gmail
	if err := gm.SendMail(); err != nil {
		fmt.Printf("Mailgun Error: %s\n", err.Error())
	}

}

ToDos

  • Wrapper Sendgrid
  • Wrapper Mailgun
  • Wrapper Gmail
  • Wrapper AWS SES
  • Simple SSL SMTP
  • Tests

Autors

  • Thiago Z S - @thiagozs (Github) / @thiagozs (Twitter)

About

Wrapper of SDKs(SendGrid, MailGun, Gmail, AWS SES, SSL SMTP) Mailer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages