Yet another SMTP client!
This package currently supports the following:
- From, To, Bcc, and Cc fields
- Email addresses in both "[email protected]" and "First Last <[email protected]>" format
- Text and HTML Message Body
- Attachments
- Read Receipts
- Custom Headers
- SMTP Logging
- Integrated Client Settings
go get github.com/BourgeoisBear/email.v2
oCfg := SMTPClientConfig{
Server: "mx.test.com",
Port: 587,
Username: "[email protected]",
Password: "...",
Mode: ModeSTARTTLS,
// SMTPLog: "-", // note: uncomment to log SMTP session to STDOUT
}
oEmail := NewEmail()
oEmail.From = "[email protected]"
oEmail.To = []string{"[email protected]"}
oEmail.Subject = "Test Message"
oEmail.Text = []byte("Whoomp there it is!")
E := oCfg.SimpleSend(oEmail)
if E != nil { return E }
This is a fork of https://github.com/jordan-wright/email
- ripped out connection pooling (sending via long-term connections to SMTP servers has not been reliable)
- condensed multiple Send... methods into NewClient() & Send() to
- provide a more generic way of establishing unauthenticated, SSL, and STARTTLS connections
- send multiple messages from within a single established SMTP session
- make direct use of outside net.Conn interfaces, so as to set dial and I/O deadlines
- added
LoginAuth
authentication interface for use with Office 365 - added
TextprotoLogged
for full logging of SMTP traffic
To run unit tests, add the proper credentials to email_test_settings.json
for accounts you choose to test with. Examples for O365, GMAIL, & CUSTOM have been provided.