Documentation
¶
Index ¶
- func LoginAuth(username, password string) smtp.Auth
- type Attachment
- type AuthMechanism
- type Driver
- type EmailAddress
- type MailGunConfig
- type MailGunDriver
- func (m *MailGunDriver) Send() error
- func (m *MailGunDriver) SetAttachments(attachments []Attachment) error
- func (m *MailGunDriver) SetBCC(bccList []mail.Address) error
- func (m *MailGunDriver) SetCC(ccList []mail.Address) error
- func (m *MailGunDriver) SetFrom(from mail.Address) error
- func (m *MailGunDriver) SetHTMLBody(body string) error
- func (m *MailGunDriver) SetPlainTextBody(body string) error
- func (m *MailGunDriver) SetSubject(Subject string) error
- func (m *MailGunDriver) SetTo(toList []mail.Address) error
- type Mailer
- func (m *Mailer) Send() error
- func (m *Mailer) SetAttachments(attachments []Attachment) *Mailer
- func (m *Mailer) SetBCC(emailAddresses []EmailAddress) *Mailer
- func (m *Mailer) SetCC(emailAddresses []EmailAddress) *Mailer
- func (m *Mailer) SetFrom(emailAddress EmailAddress) *Mailer
- func (m *Mailer) SetHTMLBody(body string) *Mailer
- func (m *Mailer) SetPlainTextBody(body string) *Mailer
- func (m *Mailer) SetSubject(subject string) *Mailer
- func (m *Mailer) SetTo(emailAddresses []EmailAddress) *Mailer
- type SMTPConfig
- type SendGridConfig
- type SendGridDriver
- func (s *SendGridDriver) Send() error
- func (s *SendGridDriver) SetAttachments(attachments []Attachment) error
- func (s *SendGridDriver) SetBCC(bccList []mail.Address) error
- func (s *SendGridDriver) SetCC(ccList []mail.Address) error
- func (s *SendGridDriver) SetFrom(from mail.Address) error
- func (s *SendGridDriver) SetHTMLBody(body string) error
- func (s *SendGridDriver) SetPlainTextBody(body string) error
- func (s *SendGridDriver) SetSubject(Subject string) error
- func (s *SendGridDriver) SetTo(toList []mail.Address) error
- type SparkPostConfig
- type SparkPostDriver
- func (s *SparkPostDriver) Send() error
- func (s *SparkPostDriver) SetAttachments(attachments []Attachment) error
- func (s *SparkPostDriver) SetBCC(bccList []mail.Address) error
- func (s *SparkPostDriver) SetCC(ccList []mail.Address) error
- func (s *SparkPostDriver) SetFrom(from mail.Address) error
- func (s *SparkPostDriver) SetHTMLBody(body string) error
- func (s *SparkPostDriver) SetPlainTextBody(body string) error
- func (s *SparkPostDriver) SetSubject(Subject string) error
- func (s *SparkPostDriver) SetTo(toList []mail.Address) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
type AuthMechanism ¶ added in v1.2.3
type AuthMechanism string
AuthMechanism selects the SMTP authentication mechanism used by the driver.
const ( // AuthAuto lets the driver query the server's advertised AUTH capabilities // (after STARTTLS) and pick the best one: LOGIN when offered (accepted by // Outlook/Office 365, Gmail, Amazon SES, Mailgun, SendGrid, Postmark and // virtually all major providers), falling back to PLAIN for legacy servers // that only support it. This is the default when AuthMechanism is empty. AuthAuto AuthMechanism = "auto" // AuthLogin forces the AUTH LOGIN mechanism. AuthLogin AuthMechanism = "login" // AuthPlain forces the AUTH PLAIN mechanism (legacy servers only). AuthPlain AuthMechanism = "plain" // AuthXOAuth2 selects the AUTH XOAUTH2 mechanism. This is groundwork for // Microsoft's progressive removal of basic authentication; it is not yet // implemented and returns a descriptive error when selected. AuthXOAuth2 AuthMechanism = "xoauth2" )
type Driver ¶
type Driver interface {
Send() error
SetFrom(from mail.Address) error
SetTo(toList []mail.Address) error
SetCC(ccList []mail.Address) error
SetBCC(bccList []mail.Address) error
SetSubject(subject string) error
SetHTMLBody(body string) error
SetPlainTextBody(body string) error
SetAttachments(attachments []Attachment) error
}
type EmailAddress ¶
type MailGunConfig ¶
type MailGunDriver ¶
type MailGunDriver struct {
// contains filtered or unexported fields
}
func (*MailGunDriver) Send ¶
func (m *MailGunDriver) Send() error
func (*MailGunDriver) SetAttachments ¶
func (m *MailGunDriver) SetAttachments(attachments []Attachment) error
func (*MailGunDriver) SetHTMLBody ¶
func (m *MailGunDriver) SetHTMLBody(body string) error
func (*MailGunDriver) SetPlainTextBody ¶
func (m *MailGunDriver) SetPlainTextBody(body string) error
func (*MailGunDriver) SetSubject ¶
func (m *MailGunDriver) SetSubject(Subject string) error
type Mailer ¶
type Mailer struct {
// contains filtered or unexported fields
}
func NewMailerWithMailGun ¶
func NewMailerWithMailGun(config *MailGunConfig) *Mailer
Initiate the mailer with MailGun driver
func NewMailerWithSMTP ¶
func NewMailerWithSMTP(config *SMTPConfig) *Mailer
Initiate the mailer with SMTP driver
func NewMailerWithSendGrid ¶
func NewMailerWithSendGrid(config *SendGridConfig) *Mailer
Initiate the mailer with SendGrid driver
func NewMailerWithSparkPost ¶
func NewMailerWithSparkPost(config *SparkPostConfig) *Mailer
Initiate the mailer with SparkPost driver
func (*Mailer) SetAttachments ¶
func (m *Mailer) SetAttachments(attachments []Attachment) *Mailer
Add attachments to the email
func (*Mailer) SetBCC ¶
func (m *Mailer) SetBCC(emailAddresses []EmailAddress) *Mailer
List of bcc of the email
func (*Mailer) SetCC ¶
func (m *Mailer) SetCC(emailAddresses []EmailAddress) *Mailer
List of cc of the email
func (*Mailer) SetFrom ¶
func (m *Mailer) SetFrom(emailAddress EmailAddress) *Mailer
Sender of the email
func (*Mailer) SetHTMLBody ¶
Set the body of the email in html format make sure to use only one version of the email body, either the html or the plain text to use the html, call the function SetHTMLBody(body string) and if you want to use the text, call the function SetPlainTextBody(body string)
func (*Mailer) SetPlainTextBody ¶
Set the body of the email in plain text format make sure to use only one version of the email body, either the html or the plain text to use the html, call the function SetHTMLBody(body string) and if you want to use the text, call the function SetPlainTextBody(body string)
func (*Mailer) SetTo ¶
func (m *Mailer) SetTo(emailAddresses []EmailAddress) *Mailer
List of receivers of the email
type SMTPConfig ¶
type SMTPConfig struct {
Host string
Port int
Username string
Password string
TLSConfig tls.Config
// AuthMechanism selects the authentication mechanism. When left empty it
// defaults to AuthAuto (dynamic selection: prefer LOGIN, fall back to
// PLAIN). Set it to AuthLogin or AuthPlain to force a specific mechanism.
// Existing configurations that omit this field keep working unchanged.
AuthMechanism AuthMechanism
// AccessToken holds an OAuth2 access token for XOAUTH2 authentication.
// Groundwork for the future XOAUTH2 support; unused for now.
AccessToken string
}
type SendGridConfig ¶
type SendGridConfig struct {
Host string // "https://api.sendgrid.com"
Endpoint string // "/v3/mail/send"
ApiKey string // SENDGRID_API_KEY
}
type SendGridDriver ¶
type SendGridDriver struct {
// contains filtered or unexported fields
}
func (*SendGridDriver) Send ¶
func (s *SendGridDriver) Send() error
func (*SendGridDriver) SetAttachments ¶
func (s *SendGridDriver) SetAttachments(attachments []Attachment) error
func (*SendGridDriver) SetHTMLBody ¶
func (s *SendGridDriver) SetHTMLBody(body string) error
func (*SendGridDriver) SetPlainTextBody ¶
func (s *SendGridDriver) SetPlainTextBody(body string) error
func (*SendGridDriver) SetSubject ¶
func (s *SendGridDriver) SetSubject(Subject string) error
type SparkPostConfig ¶
type SparkPostConfig struct {
BaseUrl string // example: https://api.sparkpost.com
ApiKey string // SPARKPOST_API_KEY
ApiVersion int // example: 1
}
type SparkPostDriver ¶
type SparkPostDriver struct {
// contains filtered or unexported fields
}
func (*SparkPostDriver) Send ¶
func (s *SparkPostDriver) Send() error
func (*SparkPostDriver) SetAttachments ¶
func (s *SparkPostDriver) SetAttachments(attachments []Attachment) error
func (*SparkPostDriver) SetHTMLBody ¶
func (s *SparkPostDriver) SetHTMLBody(body string) error
func (*SparkPostDriver) SetPlainTextBody ¶
func (s *SparkPostDriver) SetPlainTextBody(body string) error
func (*SparkPostDriver) SetSubject ¶
func (s *SparkPostDriver) SetSubject(Subject string) error
