htmlemailer

package module
v0.0.0-...-d73eb34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2017 License: BSD-3-Clause Imports: 13 Imported by: 0

README

go-htmlemailer

a simple utility to send html based emails via SMTP or Mailgun

the overall goal is to offer a way to send the verification step of your signups or to send an email for password resets.

The SSL/TLS part was adapted from https://gist.github.com/chrisgillis/10888032

This is a very simple email module you can use to send html based emails.

I include an example html email template you can adapt for your site for email signups.

Please note, in order to use Mailgun, you will need the keys you were issued by Mailgun and

You will need to verify your domain before you can send test emails to their system through

the api. If you do try to use the api with just a sandbox testing domain they issue, you will get an error like

Rejected: '....' Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.:

To run the test for mailgun, you need to set a couple of environment variables

export FROMEMAIL= export TOEMAIL= export MG_DOMAIN= export MG_API_KEY= export MG_PUBLIC_API_KEY= export MG_URL=https://api.mailgun.net/v3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailConfig

type EmailConfig struct {
	ServerName string `json:"servername"`
	UserName   string `json:"username"`
	Password   string `json:"password"`
	Key        string `json:"-"`
	PublicKey  string `json:"publickey"`
	Domain     string `json:"domain"`
}

func (*EmailConfig) HasMailGunConfigExplicitlySet

func (c *EmailConfig) HasMailGunConfigExplicitlySet() bool

func (*EmailConfig) LoadMailGunConfigFromEnv

func (c *EmailConfig) LoadMailGunConfigFromEnv() bool

func (*EmailConfig) Send

func (c *EmailConfig) Send(m *EmailMessage) (string, error)

func (*EmailConfig) SendMailGun

func (c *EmailConfig) SendMailGun(m *EmailMessage) (string, error)

func (*EmailConfig) SendSMTP

func (c *EmailConfig) SendSMTP(m *EmailMessage) (string, error)

type EmailMessage

type EmailMessage struct {
	// the full HTML content to be sent
	HTML string `json:"html,omitempty"`
	// optional full text content to be sent
	Text string `json:"text,omitempty"`
	// the message subject
	Subject string `json:"subject,omitempty"`
	// the sender email address.
	FromEmail string `json:"from_email,omitempty"`
	// optional from name to be used
	FromName string `json:"from_name,omitempty"`
	// the email address of the recipient
	ToEmail string `json:"email"`
	// the optional display name to use for the recipient
	Name string `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL