Language & Framework guides
Next.js - Typescript - Javascript - Python - PHP - Laravel - Go
A Go client library for the Shoutbox email service, supporting both REST API and SMTP implementations.
For these integrations to work, you will need an account on Shoutbox.net. You can create and copy the required API key on the Shoutbox.net dashboard!
The API key is required for any call to the Shoutbox.net backend; for SMTP, the API key is your password and 'shoutbox' the user to send emails.
go get github.com/shoutboxnet/shoutbox-go
Create a .env
file based on the template:
make env-template # Creates .env.template
cp .env.template .env
Then edit .env
with your credentials:
SHOUTBOX_API_KEY=your_api_key_here
[email protected]
[email protected]
make help # Show available commands
make build # Build the main program
make run # Run the main program (requires env vars)
make test # Run tests (requires env vars)
make run-rest # Run REST API example
make run-smtp # Run SMTP example
make clean # Clean build artifacts
make env-template # Create .env.template file
package main
import (
"context"
"log"
"os"
"github.com/shoutboxnet/shoutbox-go/shoutbox"
)
func main() {
client := shoutbox.NewClient(os.Getenv("SHOUTBOX_API_KEY"))
req := &shoutbox.EmailRequest{
From: "[email protected]",
To: "[email protected]",
Subject: "Hello World",
HTML: "<h1>Welcome!</h1>",
}
err := client.SendEmail(context.Background(), req)
if err != nil {
log.Fatal(err)
}
}
package main
import (
"log"
"os"
"github.com/shoutboxnet/shoutbox-go/shoutbox"
)
func main() {
client := shoutbox.NewSMTPClient(os.Getenv("SHOUTBOX_API_KEY"))
msg := &shoutbox.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Hello World",
HTML: "<h1>Welcome!</h1>",
}
err := client.SendEmail(msg)
if err != nil {
log.Fatal(err)
}
}
attachment, err := shoutbox.NewAttachmentFromFile("document.pdf")
if err != nil {
log.Fatal(err)
}
msg := &shoutbox.EmailMessage{
From: "[email protected]",
To: []string{"[email protected]"},
Subject: "Document Attached",
HTML: "<h1>Please find the document attached</h1>",
Attachments: []shoutbox.Attachment{attachment},
}
- REST API and SMTP support
- File attachments
- Custom headers
- Reply-to address
- Sender name
- Email validation
- Context support (REST API)
- Comprehensive testing
Set up environment variables in .env
file and run:
make test
Check the examples
directory for complete usage examples:
examples/rest
: REST API implementation exampleexamples/smtp
: SMTP implementation example with attachments
Run examples using:
make run-rest # Run REST API example
make run-smtp # Run SMTP example
- 60 requests per minute per API key
- Maximum attachment size: 10MB
- Maximum recipients per email: 50
MIT License