mailer

package module
v0.0.0-...-050fdaa Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: MIT Imports: 7 Imported by: 0

README

go-mailer

📬 GO Mailer

go-mailer is a simple Go module for email sending

Overview

Help you sending email in the simple and easy way using either SMTP or SMTP over SSL connection.

Installation

go get github.com/irnes/go-mailer

Importing

import (
    "github.com/irnes/go-mailer"
)

LICENSE

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string
	Port int
	User string
	Pass string
}

Config represents smtp configuration

type Mail

type Mail struct {
	// Sender Name
	FromName string
	// Sender email address
	From string

	// List of recipients
	To  []string
	Cc  []string
	Bcc []string

	// Mail subject as UTF-8 string
	Subject string

	// Headers are the headers
	Headers map[string]string

	// Body provides the actual body of the mail.
	// It has to be UTF-8 encoded, or you must set the Content-Type Header
	Body string
}

Mail struct represents an e-Mail

func NewMail

func NewMail() *Mail

NewMail returns a new Mail struct with initialized headers

func (*Mail) Raw

func (m *Mail) Raw() []byte

Raw returns a raw message content according to RFC 822-style

func (*Mail) SetBcc

func (m *Mail) SetBcc(addresses ...string)

SetBcc sets mail BCC recepients

func (*Mail) SetCc

func (m *Mail) SetCc(addresses ...string)

SetCc sets mail CC recepients

func (*Mail) SetHeader

func (m *Mail) SetHeader(k, v string)

SetHeader sets mail custom headers

func (*Mail) SetTo

func (m *Mail) SetTo(addresses ...string)

SetTo sets mail TO recepients

type Mailer

type Mailer interface {
	Send(*Mail) error
}

Mailer is an interface with a Send method, that dispatches a single Mail

func NewMailer

func NewMailer(config Config, ssl bool) Mailer

NewMailer returns a new Mailer using provided configuration

type SMTP

type SMTP struct {
	Config
}

SMTP client session object. If a server advertise STARTTLS, it will encrypt all further communication after initial handshake

func (*SMTP) Send

func (m *SMTP) Send(mail *Mail) (err error)

Send an email and waits for the process to end, giving proper error feedback

type SMTPSLL

type SMTPSLL struct {
	Config
}

SMTPSLL client session object for situations where SSL is required from the beginning of the connection and using STARTTLS is not appropriate

func (*SMTPSLL) Send

func (m *SMTPSLL) Send(mail *Mail) (err error)

Send an email and waits for the process to end, giving proper error feedback

Jump to

Keyboard shortcuts

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