email

package module
v0.0.0-...-637183b Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: GPL-3.0 Imports: 1 Imported by: 7

README

Messages Email API

Microservice implemented from Messages Core is responsible for sending emails through several providers such as Sendgrid, Mandrill or AWS SES.

As explained in the Messages Core repository, it can be seen that there are three models, messages, channel and provider. To know more you can read the readme of Messages Core.

Channels

Corresponds to the type of notification that could be sent, for this there must be the implementation of that channel as a gRPC service through an API.

Providers

The provider is an attribute of channel and allows to identify what types of messages are available for a specific channel.

In this api we will find the implementation of only 3 providers. Find Providers implementation at the ./provider folder.

Name Description ENV (each with prefix PROVIDER_)
Sendgrid Free Send 40,000 month. SENDGRID_API_KEY: string
Mandrill Free Send 10,000 month. MANDRIL_API_KEY: string
AWS SES $0.10 for every 1,000 emails. SES_AWS_KEY_ID, SES_AWS_SECRET_KEY, SES_AWS_REGION: string

Model

Email {
  from:       string
  from_name:  string
  to:         []string
  reply_to:   []string
  subject:    string
  text:       string
  html:       string
  provider:   string  // sendgrid, mandrill, ses
}

Service methods

Send(e *email.Message, delay int64) (string, error): send email message with delay, use delay=0 for send right now.

Get(ID string) (*email.Message, error): get email message by id.

Update(ID string, e *email.Message) error: update email message by id.

Cancel(ID string) error: cancel email message by id.

Environments Values

HOST: define email service host.

PORT: define email service port.

REDIS_HOST: define redis host.

REDIS_PORT: define redis port.

REDIS_DATABASE: define redis database number.

PROVIDERS: define string with providers separated by comma.

PROVIDER_SENDGRID_API_KEY: define sendgrid provider api key.

PROVIDER_MANDRILL_API_KEY: define mandrill provider api key.

PROVIDER_SES_AWS_KEY_ID: define aws key id.

PROVIDER_SES_AWS_SECRET_KEY: define aws secret key.

PROVIDER_SES_AWS_REGION: define aws region.

Commands (Development)

make build: build restaurants service for osx.

make linux: build restaurants service for linux os.

make docker .: build docker.

make compose: start docker-docker.

make stop: stop docker-docker.

make run: run email service.

docker run -it -p 5030:5030 email-api: run docker.

Documentation

Index

Constants

View Source
const (
	// Channel ...
	Channel = "email"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MailingTemplates

type MailingTemplates struct {
	Signup          func(u *users.User) error
	VerifyEmail     func(u *users.User, token string) error
	ForgotPassword  func(u *users.User, token string) error
	PasswordChanged func(u *users.User) error
}

MailingTemplates ...

type Message

type Message struct {
	From     string   `json:"from"`
	FromName string   `json:"from_name"`
	To       []string `json:"to"`
	ReplyTo  []string `json:"reply_to"`
	Subject  string   `json:"subject"`
	Text     string   `json:"text"`
	HTML     string   `json:"html"`
	Provider string   `json:"provider"`
	Status   string   `json:"status"`
}

Message ...

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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