Documentation ¶
Overview ¶
Package mailer is a simple e-mail sender for the Go Programming Language.
Index ¶
- Constants
- type Config
- type Mailer
- func (m *Mailer) Send(subject string, body string, to ...string) error
- func (m *Mailer) SendWithBytes(subject string, body []byte, to ...string) error
- func (m *Mailer) SendWithReadCloser(subject string, bodyReader io.ReadCloser, to ...string) error
- func (m *Mailer) SendWithReader(subject string, bodyReader io.Reader, to ...string) error
- func (m *Mailer) UpdateConfig(cfg Config)
Constants ¶
const (
// Version current version semantic number of the "go-mailer" package.
Version = "0.1.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Host is the server mail host, IP or address. Host string // Port is the listening port. Port int // Username is the auth username@domain.com for the sender. Username string // Password is the auth password for the sender. Password string // FromAddr is the 'from' part of the mail header, it overrides the username. FromAddr string // FromAlias is the from part, if empty this is the first part before @ from the Username field. FromAlias string // UseCommand enable it if you want to send e-mail with the mail command instead of smtp. // // Host,Port & Password will be ignored. // ONLY FOR UNIX. UseCommand bool }
Config contains those necessary fields that Mailer needs to send e-mails.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default configs for Mailer returns just an empty Config struct.
type Mailer ¶ added in v0.1.0
type Mailer struct {
// contains filtered or unexported fields
}
Mailer is the main struct which contains the nessecary fields for sending emails, either with unix command "sendmail" or by following the configuration's properties.
func (*Mailer) Send ¶ added in v0.1.0
Send sends an email to the recipient(s) the body can be in HTML format as well.
Note: you can change the UseCommand in runtime.
func (*Mailer) SendWithBytes ¶ added in v0.1.0
SendWithBytes same as `Send` but it accepts the body as raw []byte, it's the fastest method to send e-mails.
func (*Mailer) SendWithReadCloser ¶ added in v0.1.0
SendWithReadCloser same as `SendWithReader` but it closes the reader at the end.
func (*Mailer) SendWithReader ¶ added in v0.1.0
SendWithReader same as `Send` but it accepts an io.Reader that body can be retrieved and call the `SendWithBytes`.
func (*Mailer) UpdateConfig ¶ added in v0.1.0
UpdateConfig overrides the current configuration.