Skip to content

epa-datos/mailing

Repository files navigation

mailing

Summary

EPA digital mailing package

Motivation

  • This package aims to provide a simple API for mailing services.
  • This package connects with the following mailing providers:
    • Mailgun
  • This package allows:
    • Sending single emails

API

To start using this package you need to include the following lines in your imports

import(
	"github.com/epa-datos/mailing"
	"github.com/epa-datos/mailing/services/{MAILING_SERVICE}"
 )

Sending a single email

To send an email you need to use the following method

  err := mail.SendSingleEmail(headers, template, params)

Single emails have three input values:
Headers

  headers := &mailing.Headers{
  	Sender:    "test@epa.com",
	Recipient: "recipient@test.com",
	Subject:   "test",
	ContentType: "text/html",           //This value is optional
   }	

Template

  template := mailing.TestTemplate      //This is a constant of type template. Valid templates are defined in mailing/templates.go

Params

 params := map[string]interface{}{
   "Example":"test",                   //Valid params depend on template placeholders
 }

Mailgun specific implementation

	mailService := mailgunService.New()

Note: You need to set the EMAIL_DOMAIN and EMAIL_API_KEY as environment variables

About

Package for email services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published