Version: v0.0.0-...-41ef739 Latest Latest

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

Go to latest
Published: Dec 24, 2016 License: MIT Imports: 15 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Message

type Message struct {
	// contains filtered or unexported fields

Message represents a mail message to be sent. At the very minimum a message must contain a from address, a to address. Everything else is optional.

func NewEmpty

func NewEmpty() *Message

NewEmpty creates a new go-mail Message object that is completely empty (no headers). You must use this to create an empty Message object as there are internal members that need to be instantiated.

func NewSimple

func NewSimple(from string, to string, subject string, bodyText string, attachmentFilePaths ...string) (*Message, error)

NewSimple creates a simple go-mail Message with a bare minimum of headers set. The following lists the headers set and their values. "From" - with the address provided. "To" - with the address provided. To add more, use the AddMailHeader method and headers.To() helper function. "MIME-Version" - "1.0"

Addresses can be in the following formats - Simple Email - Email with Name - Chris Tomich <>

func (*Message) AddAttachment

func (m *Message) AddAttachment(attachment *attachments.EmbeddedBinaryObject, err error) error

AddAttachment will add an attachment to the email.

func (*Message) AddMailHeader

func (m *Message) AddMailHeader(key, value string)

AddMailHeader adds a header to the email given the key and value. Look in the headers package to see a number of helpers for potential headers.

func (*Message) GenerateMessage

func (m *Message) GenerateMessage() (*bytes.Buffer, error)

GenerateMessage will create a buffer containing the email message in it's current state.

func (*Message) RemoveAttachment

func (m *Message) RemoveAttachment(filename string)

RemoveAttachment will remove the attachment from the email.

func (*Message) SetHTMLBody

func (m *Message) SetHTMLBody(body *body.MailBody, images ...*attachments.EmbeddedBinaryObject)

SetHTMLBody will set/overwrite the body for the HTML portion of the email and override all currently stored images. This body is additional to the text-only body and does not impact anything set with SetTextBody().

func (*Message) SetTextBody

func (m *Message) SetTextBody(body *body.MailBody)

SetTextBody will set/overwrite the body for the text-only portion of the email. This body is additional to the HTML body and does not impact anything set with SetHTMLBody().

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL