Documentation
¶
Overview ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
Attachment represents an email attachment
type ContentType ¶
type ContentType int
ContentType represents content type
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 )
func (ContentType) String ¶
func (contentType ContentType) String() string
type Dialer ¶
type Dialer struct {
Server string
Port int
TLS bool
Account string
Password string
Timeout time.Duration
}
Dialer is a dialer to an SMTP server.
func (*Dialer) Dial ¶
Dial dials the SMTP server and performs optional STARTTLS / AUTH. It returns a connected smtp.Client. Caller should call client.Quit() when done.
func (*Dialer) Send ¶
Send sends the given messages using one established connection. It honors Dialer.Timeout for each message via context timeouts. The client connection will be Quit() when Send returns.
func (*Dialer) SendMail ¶
SendMail connects to the server at Dialer's addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.
The addresses in the to parameter are the SMTP RCPT addresses.
The msg parameter should be an RFC 822-style email with headers first, a blank line, and then the message body. The lines of msg should be CRLF terminated. The msg headers should usually include fields such as "From", "To", "Subject", and "Cc". Sending "Bcc" messages is accomplished by including an email address in the to parameter but not including it in the msg headers.
type Message ¶
type Message struct {
From *mail.Address
To, Cc, Bcc Receipts
Subject string
Body string
ContentType ContentType
Attachments []*Attachment
}
Message represents an email message
func (*Message) Bytes ¶
Bytes renders the RFC822-style message bytes for the message. id is used to create the Message-ID domain if provided; if empty, fallback to hostname. The produced message uses CRLF line endings as required by SMTP and includes correct MIME headers for single-part or multipart/mixed with attachments.
type Receipts ¶
Receipts represents a list of mail addresses.
func ParseReceipts ¶
ParseReceipts parses a comma/semicolon separated list of addresses into Receipts.
func (Receipts) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It encodes the receipts as a JSON array of email address strings.
func (Receipts) MarshalText ¶
MarshalText implements encoding.TextMarshaler and returns the RFC5322 representation.
func (Receipts) String ¶
String returns the addresses joined in the standard RFC 5322 way using the String method of mail.Address.
func (*Receipts) UnmarshalJSON ¶
UnmarshalJSON supports either a single string (comma separated) or an array of strings.
func (*Receipts) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler