Version: v0.7.1 Latest Latest

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 17 Imported by: 1




View Source
const (
	// FailUnknown is the default FailureID
	FailUnknown failures.FailureID = iota
	// FailGetSMTPClient is returned when a SMTP client could not be created
	// FailEnableStartTLS is returned when failing to enable StartTLS
	// FailAuthType is returned when the Auth type could not be identified
	// FailAuthenticating is returned when the authentication fails
	// FailSendRecipient is returned when sending to a recipient fails
	// FailClosingSession is returned when the server doesn't accept the QUIT command
	// FailPlainHeader is returned when the text/plain multipart header could not be set
	// FailHTMLHeader is returned when the text/html multipart header could not be set
	// FailMultiEndHeader is returned when the multipart end header could not be set
	// FailMessageTemplate is returned when the message template could not be written to the stream
	// FailMessageRaw is returned when a non-templated message could not be written to the stream
	// FailSetSender is returned when the server didn't accept the sender address
	// FailSetRecipient is returned when the server didn't accept the recipient address
	// FailOpenDataStream is returned when the server didn't accept the data stream
	// FailWriteHeaders is returned when the headers could not be written to the data stream
	// FailCloseDataStream is returned when the server didn't accept the data stream contents
	// FailConnectToServer is returned when the TCP connection to the server failed
	// FailCreateSMTPClient is returned when the smtp.Client initialization failed
	// FailApplySendParams is returned when updating the send config failed
	// FailHandshake is returned when the initial HELLO handshake returned an error
View Source
const ImplicitTLSPort = 465

ImplicitTLSPort is de facto standard SMTPS port

View Source
const Scheme = "smtp"

Scheme is the identifying part of this service's configuration URL


View Source
var AuthTypes = &authTypeVals{
	None:    0,
	Plain:   1,
	CRAMMD5: 2,
	Unknown: 3,
	OAuth2:  4,
	Enum: format.CreateEnumFormatter(

AuthTypes is the enum helper for populating the Auth field

View Source
var EncMethods = &encMethodVals{
	None:        0,
	ExplicitTLS: 1,
	ImplicitTLS: 2,
	Auto:        3,

	Enum: format.CreateEnumFormatter(

EncMethods is the enum helper for populating the Encryption field


func OAuth2Auth

func OAuth2Auth(username, accessToken string) smtp.Auth

OAuth2Auth returns an Auth that implements the SASL XOAUTH2 authentication as per


type Config

type Config struct {
	Host        string    `desc:"SMTP server hostname or IP address" url:"Host"`
	Username    string    `desc:"SMTP server username" default:"" url:"User"`
	Password    string    `desc:"SMTP server password or hash (for OAuth2)" default:"" url:"Pass"`
	Port        uint16    `desc:"SMTP server port, common ones are 25, 465, 587 or 2525" default:"25" url:"Port"`
	FromAddress string    `desc:"E-mail address that the mail are sent from" key:"fromaddress,from"`
	FromName    string    `desc:"Name of the sender" optional:"yes" key:"fromname"`
	ToAddresses []string  `desc:"List of recipient e-mails separated by \",\" (comma)" key:"toaddresses,to"`
	Subject     string    `desc:"The subject of the sent mail" key:"subject,title" default:"Shoutrrr Notification"`
	Auth        authType  `desc:"SMTP authentication method" key:"auth" default:"Unknown"`
	Encryption  encMethod `desc:"Encryption method" default:"Auto" key:"encryption"`
	UseStartTLS bool      `desc:"Whether to use StartTLS encryption" default:"Yes" key:"usestarttls,starttls"`
	UseHTML     bool      `desc:"Whether the message being sent is in HTML" default:"No" key:"usehtml"`
	ClientHost  string    `` /* 155-byte string literal not displayed */

Config is the configuration needed to send e-mail notifications over SMTP

func (*Config) Clone

func (config *Config) Clone() Config

Clone returns a copy of the config

func (Config) Enums

func (config Config) Enums() map[string]types.EnumFormatter

Enums returns the fields that should use a corresponding EnumFormatter to Print/Parse their values

func (*Config) FixEmailTags added in v0.7.0

func (config *Config) FixEmailTags()

FixEmailTags replaces parsed spaces (+) in e-mail addresses with '+'

func (*Config) GetURL

func (config *Config) GetURL() *url.URL

GetURL returns a URL representation of it's current field values

func (*Config) SetURL

func (config *Config) SetURL(url *url.URL) error

SetURL updates a ServiceConfig from a URL representation of it's field values

type Service

type Service struct {
	// contains filtered or unexported fields

Service sends notifications to a given e-mail addresses via SMTP

func (*Service) Initialize

func (service *Service) Initialize(configURL *url.URL, logger types.StdLogger) error

Initialize loads ServiceConfig from configURL and sets logger for this Service

func (*Service) Send

func (service *Service) Send(message string, params *types.Params) error

Send a notification message to e-mail recipients

Jump to

Keyboard shortcuts

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