https://github.com/spacetab-io/mails-go
Email sending library
https://github.com/spacetab-io/mails-go
Last synced: about 1 month ago
JSON representation
Email sending library
- Host: GitHub
- URL: https://github.com/spacetab-io/mails-go
- Owner: spacetab-io
- License: mit
- Created: 2022-06-01T14:20:06.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T14:37:26.000Z (almost 3 years ago)
- Last Synced: 2025-02-14T22:13:51.405Z (3 months ago)
- Language: Go
- Size: 19.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mails-go
Golang library for email sending.
## Providers
List of available providers:
* [Sendgrid](github.com/sendgrid/sendgrid-go)
* [Mandrill](github.com/mattbaird/gochimp)
* [Mailgun](github.com/mailgun/mailgun-go/v4)
* [SMTP](github.com/xhit/go-simple-mail/v2)
* log
* file## Usage
```go
package mainimport (
"context"
"time""github.com/spacetab-io/configuration-structs-go/v2/configuration/mimetype"
"github.com/spacetab-io/configuration-structs-go/v2/mailing"
"github.com/spacetab-io/mails-go/contracts"
"github.com/spacetab-io/mails-go/providers"
)func main() {
// 1. Get Provider config (with should implement mailing.MailProviderConfigInterface
// For Example, Sendgrid Config
sendgridCfg := mailing.SendgridConfig{
Enabled: true,
Key: "APIKey",
SendTimeout: 5 * time.Second,
}// 2. Initiate provider
// Sendgrid provider
sendgrid, err := providers.NewSendgrid(sendgridCfg)
if err != nil {
panic(err)
}// 3. Prepare Message with should implement contracts.MessageInterface
msg := contracts.Message{
To: mailing.MailAddressList{
{Email: "[email protected]", Name: "To One"},
{Email: "[email protected]", Name: "To Two"},
},
MimeType: mime.TextPlain,
Subject: "Test email",
Content: []byte("test email content"),
}// 4. Send message
if err := sendgrid.Send(context.Background(), msg); err != nil {
panic(err)
}
}
```