Documentation ¶
Overview ¶
Package mail is a mail delivery plugin based on SMTP.
Index ¶
- Constants
- func LoginAuth(username, password string) smtp.Auth
- type Email
- func (e *Email) AddBcc(bcc ...string) *Email
- func (e *Email) AddCc(cc ...string) *Email
- func (e *Email) AddTo(to ...string) *Email
- func (e *Email) AttachFile(filename string) (*email.Attachment, error)
- func (e *Email) SetFrom(from string) *Email
- func (e *Email) SetHTML(body string) *Email
- func (e *Email) SetHeader(k, v string) *Email
- func (e *Email) SetSubject(subject string) *Email
- func (e *Email) SetText(text string) *Email
- type SMTPAuthType
- type SMTPClient
- type SMTPEncryptionType
Constants ¶
const ( // SMTPEncryptionTypeNone is the NONE encrypt type of SMTP. SMTPEncryptionTypeNone = iota // SMTPEncryptionTypeSSLTLS is the SSL/TLS encrypt type of SMTP. SMTPEncryptionTypeSSLTLS // SMTPEncryptionTypeSTARTTLS is the STARTTLS encrypt type of SMTP. SMTPEncryptionTypeSTARTTLS )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email is the email to be sent.
func (*Email) AddTo ¶
AddTo adds the to address of the SMTP client. Only accept the valid RFC 5322 address, e.g. "Name <user@domain.com>".
func (*Email) AttachFile ¶
func (e *Email) AttachFile(filename string) (*email.Attachment, error)
AttachFile attaches the file to the email, and returns the filename of the attachment. Caller can use filename as content id to reference the attachment in the email body.
func (*Email) SetFrom ¶
SetFrom sets the from address of the SMTP client. Only accept the valid RFC 5322 address, e.g. "Bytebase <support@bytebase.com>".
func (*Email) SetSubject ¶
SetSubject sets the subject of the SMTP client.
type SMTPAuthType ¶
type SMTPAuthType string
SMTPAuthType is the type of SMTP authentication.
const ( // SMTPAuthTypeNone is the NONE auth type of SMTP. SMTPAuthTypeNone SMTPAuthType = "" // SMTPAuthTypePlain is the PLAIN auth type of SMTP. SMTPAuthTypePlain SMTPAuthType = "PLAIN" // SMTPAuthTypeLogin is the LOGIN auth type of SMTP. SMTPAuthTypeLogin SMTPAuthType = "LOGIN" // SMTPAuthTypeCRAMMD5 is the CRAM-MD5 auth type of SMTP. SMTPAuthTypeCRAMMD5 SMTPAuthType = "CRAM-MD5" )
type SMTPClient ¶
type SMTPClient struct {
// contains filtered or unexported fields
}
SMTPClient is the client of SMTP.
func NewSMTPClient ¶
func NewSMTPClient(host string, port int) *SMTPClient
NewSMTPClient returns a new SMTP client.
func (*SMTPClient) SendMail ¶
func (c *SMTPClient) SendMail(e *Email, t *tls.Config) error
SendMail sends the email.
func (*SMTPClient) SetAuthCredentials ¶
func (c *SMTPClient) SetAuthCredentials(identity, username, password string) *SMTPClient
SetAuthCredentials sets the auth credentials of the SMTP client.
func (*SMTPClient) SetAuthType ¶
func (c *SMTPClient) SetAuthType(authType SMTPAuthType) *SMTPClient
SetAuthType sets the auth type of the SMTP client.
func (*SMTPClient) SetEncryptionType ¶
func (c *SMTPClient) SetEncryptionType(encryptionType SMTPEncryptionType)
SetEncryptionType sets the encryption type of the SMTP client.
type SMTPEncryptionType ¶
type SMTPEncryptionType uint
SMTPEncryptionType is the type of SMTP encryption.