Documentation ¶
Index ¶
- Constants
- type Email
- func (email *Email) AddAddresses(header string, addresses ...string) *Email
- func (email *Email) AddAlternative(contentType contentType, body string) *Email
- func (email *Email) AddAttachment(file string, name ...string) *Email
- func (email *Email) AddAttachmentBase64(b64File string, name string) *Email
- func (email *Email) AddBcc(addresses ...string) *Email
- func (email *Email) AddCc(addresses ...string) *Email
- func (email *Email) AddHeader(header string, values ...string) *Email
- func (email *Email) AddHeaders(headers textproto.MIMEHeader) *Email
- func (email *Email) AddInline(file string, name ...string) *Email
- func (email *Email) AddTo(addresses ...string) *Email
- func (email *Email) GetError() error
- func (email *Email) GetMessage() string
- func (email *Email) Send(client *SMTPClient) error
- func (email *Email) SetBody(contentType contentType, body string) *Email
- func (email *Email) SetDate(dateTime string) *Email
- func (email *Email) SetFrom(address string) *Email
- func (email *Email) SetPriority(priority priority) *Email
- func (email *Email) SetReplyTo(address string) *Email
- func (email *Email) SetReturnPath(address string) *Email
- func (email *Email) SetSender(address string) *Email
- func (email *Email) SetSubject(subject string) *Email
- type SMTPClient
- type SMTPServer
Constants ¶
const ( // EncryptionNone uses no encryption when sending email EncryptionNone encryption = iota // EncryptionSSL sets encryption type to SSL when sending email EncryptionSSL // EncryptionTLS sets encryption type to TLS when sending email EncryptionTLS )
const ( // EncodingNone turns off encoding on the message body EncodingNone encoding = iota // EncodingBase64 sets the message body encoding to base64 EncodingBase64 // EncodingQuotedPrintable sets the message body encoding to quoted-printable EncodingQuotedPrintable )
const ( // TextPlain sets body type to text/plain in message body TextPlain contentType = iota // TextHTML sets body type to text/html in message body TextHTML )
const ( // PriorityLow sets the email priority to Low PriorityLow priority = iota // PriorityHigh sets the email priority to High PriorityHigh )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Email ¶
type Email struct { Charset string Encoding encoding Error error SMTPServer *smtpClient // contains filtered or unexported fields }
Email represents an email message.
func NewMSG ¶
func NewMSG() *Email
NewMSG creates a new email. It uses UTF-8 by default. All charsets: http://webcheatsheet.com/HTML/character_sets_list.php
func (*Email) AddAddresses ¶
AddAddresses allows you to add addresses to the specified address header.
func (*Email) AddAlternative ¶
AddAlternative allows you to add alternative parts to the body of the email message. This is most commonly used to add an html version in addition to a plain text version that was already added with SetBody.
func (*Email) AddAttachment ¶
AddAttachment allows you to add an attachment to the email message. You can optionally provide a different name for the file.
func (*Email) AddAttachmentBase64 ¶
AddAttachmentBase64 allows you to add an attachment in base64 to the email message. You need provide a name for the file.
func (*Email) AddBcc ¶
AddBcc adds a Bcc address. You can provide multiple addresses at the same time.
func (*Email) AddHeaders ¶
func (email *Email) AddHeaders(headers textproto.MIMEHeader) *Email
AddHeaders is used to add multiple headers at once
func (*Email) AddInline ¶
AddInline allows you to add an inline attachment to the email message. You can optionally provide a different name for the file.
func (*Email) GetMessage ¶
GetMessage builds and returns the email message
func (*Email) Send ¶
func (email *Email) Send(client *SMTPClient) error
Send sends the composed email
func (*Email) SetDate ¶
SetDate sets the date header to the provided date/time. The format of the string should be YYYY-MM-DD HH:MM:SS Time Zone.
Example: SetDate("2015-04-28 10:32:00 CDT")
func (*Email) SetPriority ¶
SetPriority sets the email message priority. Use with either "High" or "Low".
func (*Email) SetReplyTo ¶
SetReplyTo sets the Reply-To address.
func (*Email) SetReturnPath ¶
SetReturnPath sets the Return-Path address. This is most often used to send bounced emails to a different email address.
func (*Email) SetSubject ¶
SetSubject sets the subject of the email message.
type SMTPClient ¶
SMTPClient represents a SMTP Client for send email
func (*SMTPClient) Noop ¶
func (smtpClient *SMTPClient) Noop() error
Noop send NOOP command to smtp client
func (*SMTPClient) Quit ¶
func (smtpClient *SMTPClient) Quit() error
Quit send QUIT command to smtp client
func (*SMTPClient) Reset ¶
func (smtpClient *SMTPClient) Reset() error
Reset send RSET command to smtp client
type SMTPServer ¶
type SMTPServer struct { // From string Encryption encryption Username string Password string ConnectTimeout time.Duration SendTimeout time.Duration Host string Port int KeepAlive bool }
SMTPServer represents a SMTP Server
func NewSMTPClient ¶
func NewSMTPClient() *SMTPServer
NewSMTPClient returns the client for send email
func (*SMTPServer) Connect ¶
func (server *SMTPServer) Connect() (*SMTPClient, error)
Connect returns the smtp client