Documentation ¶
Overview ¶
Package email provides utilities to connect to an SMTP server via TLS and send emails The goal of this package is to extend the smtp and mail packages from the Go standard library
This package helps you do 3 things: 1. Connecting to a SMTP server (using func email.NewClient) 2. Generating an email message string from a structured data (using struct email.Email and func email.ToMessageStr) 3. Sending emails over the same connection to the SMTP server (using func email.Send)
Index ¶
Constants ¶
const ( TextPlain = "text/plain; " + CharsetUTF8 TextHTML = "text/html; " + CharsetUTF8 CharsetUTF8 = "charset=\"UTF-8\"" MultipartAlternative = "multipart/alternative; boundary=\"" + BoundaryVal + "\"" BoundaryVal = "part" // the boundary value chosen here is arbitrary but should be consistent with the email's alternative body parts QuotedPrintable = "quoted-printable" // )
Content type values
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient returns an authenticated SMTP client or an error if the process fails When successfull, make sure to call Quit on the smtp client struct after you're done sending emails to close the connection to the SMTP server
func Send ¶
Send sends the email to the client without calling client.Quit() so that the connection can be used to send several emails A call to Send should be preceded by a call to NewClient() to connect to the server and authenticate A call to Send should ultimately be followed by a call to client.Quit() so that the SMTP client can close the server connection
func ToMessageStr ¶
ToMessageStr generates the message string that will be sent to the SMTP server