Documentation ¶
Index ¶
Constants ¶
const ( Sender = "HERMES_SENDER" Receiver = "HERMES_RECEIVER" Host = "HERMES_HOST" Port = "HERMES_PORT" Passwd = "HERMES_PASSWD" )
const (
MailNewLine = "\r\n"
)
Variables ¶
var ( ErrSenderNotSet = errSenderNotSet() ErrReceiverNotSet = errReceiverNotSet() ErrMailHostNotSet = errMailHostNotSet() ErrMailPortNotSet = errMailPortNotSet() ErrPasswdNotSet = errPasswdNotSet() )
var Version string
Functions ¶
func Hermes ¶
func Hermes(conn Connection, msg string) error
Types ¶
type Configuration ¶
type Configuration struct { Sender string Receiver string MailHost string MailPort string Passwd string }
func NewConfiguration ¶
func NewConfiguration() (*Configuration, error)
NewConfiguration is the default entry point for getting the hermes Configuration. Unless you have a good reason to do otherwise, NewConfiguration should be used over other methods. NewConfiguration uses a precedence when evaluating configuration mechanisms, the first to succeed wins. If no mechanism is able to succeed, Configuration is undefined and err != nil. Mechanism precedence is as follows: 1. Configuration file in the default location. [NewDefaultFileConfiguration()] 2. Environment variables. [NewEnvConfiguration()]
func NewDefaultFileConfiguration ¶ added in v1.1.0
func NewDefaultFileConfiguration() (*Configuration, error)
NewDefaultFileConfiguration returns a hermes Configuration with options based on a configuration file in the default location. If there is a problem reading the file, the returned Configuration is undefined and err != nil. The default location of the config file is: /opt/catloaf/etc/hermes.conf
func NewEnvConfiguration ¶ added in v1.1.0
func NewEnvConfiguration() (*Configuration, error)
NewEnvConfiguration returns a hermes Configuration with options based on environment variables. If any one of the environment variables is missing, the returned Configuration is undefined and err != nil. The following environment variables are used: HERMES_SENDER HERMES_RECEIVER HERMES_HOST HERMES_PORT HERMES_PASSWD
func NewFileConfiguration ¶ added in v1.1.0
func NewFileConfiguration(configFilePath string) (*Configuration, error)
NewFileConfiguration returns a hermes Configuration with options based on the specified configuration file. If there is a problem reading the file, the returned Configuration is undefined and err != nil.
type Connection ¶
type FileOptions ¶ added in v1.1.0
type SmtpConnection ¶
type SmtpConnection struct {
// contains filtered or unexported fields
}
func NewSmtpConnection ¶
func NewSmtpConnection(config *Configuration) (*SmtpConnection, error)
func (*SmtpConnection) From ¶
func (conn *SmtpConnection) From() string
func (*SmtpConnection) MailHost ¶
func (conn *SmtpConnection) MailHost() string
func (*SmtpConnection) SendMessage ¶
func (conn *SmtpConnection) SendMessage(msg string) error
func (*SmtpConnection) To ¶
func (conn *SmtpConnection) To() string