mail

package
v0.0.0-...-ce64a08 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mail is a mail delivery plugin based on SMTP.

Index

Constants

View Source
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

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

LoginAuth returns an Auth that implements the LOGIN authentication.

Types

type Email

type Email struct {
	// contains filtered or unexported fields
}

Email is the email to be sent.

func NewEmailMsg

func NewEmailMsg() *Email

NewEmailMsg returns a new email message.

func (*Email) AddBcc

func (e *Email) AddBcc(bcc ...string) *Email

func (*Email) AddCc

func (e *Email) AddCc(cc ...string) *Email

func (*Email) AddTo

func (e *Email) AddTo(to ...string) *Email

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

func (e *Email) SetFrom(from string) *Email

SetFrom sets the from address of the SMTP client. Only accept the valid RFC 5322 address, e.g. "Bytebase <support@bytebase.com>".

func (*Email) SetHTML

func (e *Email) SetHTML(body string) *Email

SetHTML sets the body of the SMTP client. It must be html formatted.

func (*Email) SetHeader

func (e *Email) SetHeader(k, v string) *Email

func (*Email) SetSubject

func (e *Email) SetSubject(subject string) *Email

SetSubject sets the subject of the SMTP client.

func (*Email) SetText

func (e *Email) SetText(text string) *Email

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"
)

func (SMTPAuthType) Validate

func (SMTPAuthType) Validate(in string) (bool, error)

Validate implements field.EnumValues interface

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL