https://github.com/knadh/smtppool
High throughput Go SMTP pool library with graceful handling of idle timeouts, errors, and retries.
https://github.com/knadh/smtppool
email-client email-sender pool smtp smtp-client
Last synced: 5 months ago
JSON representation
High throughput Go SMTP pool library with graceful handling of idle timeouts, errors, and retries.
- Host: GitHub
- URL: https://github.com/knadh/smtppool
- Owner: knadh
- License: mit
- Created: 2020-05-10T18:04:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-29T11:27:28.000Z (6 months ago)
- Last Synced: 2025-04-08T10:34:23.947Z (6 months ago)
- Topics: email-client, email-sender, pool, smtp, smtp-client
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 153
- Watchers: 3
- Forks: 32
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
smtppool
========smtppool is a Go library that creates a pool of reusable SMTP connections for high throughput e-mailing. It gracefully handles idle connections, timeouts, and retries. The e-mail formatting, parsing, and preparation code is forked from [jordan-wright/email](https://github.com/jordan-wright/email).
### Install
```go get github.com/knadh/smtppool/v2```#### Usage
```go
package mainimport (
"log"
"time""github.com/knadh/smtppool/v2"
)func main() {
// Try https://github.com/mailhog/MailHog for running a local dummy SMTP server.
// Create a new pool.
pool, err := smtppool.New(smtppool.Opt{
Host: "localhost",
Port: 1025,
MaxConns: 10,
IdleTimeout: time.Second * 10,
PoolWaitTimeout: time.Second * 3,
SSL: smtppool.SSLNone
})
if err != nil {
log.Fatalf("error creating pool: %v", err)
}e:= smtppool.Email{
From: "John Doe ",
To: []string{"doe@example.com"},// Optional.
Bcc: []string{"doebcc@example.com"},
Cc: []string{"doecc@example.com"},Subject: "Hello, World",
Text: []byte("This is a test e-mail"),
HTML: []byte("This is a test e-mail"),
}// Add attachments.
if _, err := e.AttachFile("test.txt"); err != nil {
log.Fatalf("error attaching file: %v", err)
}if err := pool.Send(e); err != nil {
log.Fatalf("error sending e-mail: %v", err)
}
}
```Licensed under the MIT license.