Documentation
¶
Overview ¶
Package mail sends SMTP mail. It is the one notification channel that is not a webhook, and the only one that can carry an attachment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment is a file carried by a message. SMTP is the only channel that accepts one.
type Encryption ¶
type Encryption string
Encryption selects how the SMTP connection is secured.
const ( // EncryptionAuto upgrades with STARTTLS, the same as explicit TLS. EncryptionAuto Encryption = "Auto" // EncryptionNone sends in the clear. EncryptionNone Encryption = "None" // EncryptionExplicitTLS connects in the clear then issues STARTTLS. EncryptionExplicitTLS Encryption = "ExplicitTLS" // EncryptionImplicitTLS connects with TLS from the first byte. EncryptionImplicitTLS Encryption = "ImplicitTLS" )
type Mail ¶
type Mail struct {
// contains filtered or unexported fields
}
Mail is one message under construction.
func (*Mail) AddAttachment ¶
func (m *Mail) AddAttachment(attachment Attachment) *Mail
func (*Mail) Send ¶
func (m *Mail) Send(conn SMTPConnection) error
Send delivers the message over conn.
func (*Mail) SetCredentials ¶
type SMTPConnection ¶
type SMTPConnection struct {
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"`
Username types.EnvVar `json:"username,omitempty" yaml:"username,omitempty"`
Password types.EnvVar `json:"password,omitempty" yaml:"password,omitempty"`
FromAddress string `json:"fromAddress,omitempty" yaml:"fromAddress,omitempty"`
FromName string `json:"fromName,omitempty" yaml:"fromName,omitempty"`
Encryption Encryption `json:"encryption,omitempty" yaml:"encryption,omitempty"`
Auth Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
InsecureTLS bool `json:"insecureTLS,omitempty" yaml:"insecureTLS,omitempty"`
// To is the default recipient list, used when a message names none.
To []string `json:"to,omitempty" yaml:"to,omitempty"`
}
SMTPConnection is a mail server. It is derived from a models.Connection of type email, or parsed from an smtp:// URL.
func FromConnection ¶
func FromConnection(conn *models.Connection) (SMTPConnection, error)
FromConnection projects a stored connection onto an SMTP connection. The connection must already be hydrated: this reads resolved values, it does not resolve secrets itself.
func FromURL ¶
func FromURL(raw string) (SMTPConnection, error)
FromURL parses an smtp:// URL, including the query parameters the shoutrrr URL form used, so URLs already written against the old form keep working.