package ses
import "petersanchez.com/x/carrier/ses"
Package ses is a delivery service for the carrier email message package.
Code:play
Example¶
package main
import (
"log"
"os"
"petersanchez.com/x/carrier"
"petersanchez.com/x/carrier/ses"
)
func main() {
// import (
// "petersanchez.com/x/carrier"
// "petersanchez.com/x/carrier/ses"
// )
conf := &ses.MailConfig{
AccessID: "<YOUR ACCESS KEY>",
SecretKey: "<YOUR SECRET KEY>",
}
// You should handle errors properly in all instances below
svc, err := ses.NewSESService(conf)
if err != nil {
// handle errors (here and below)
log.Fatal(err)
}
msg := carrier.NewMessage()
msg.SetFrom("me@mydomain.com").
SetTo("recipient@theirdomain.com").
SetCc("copy@somedomain.com")
msg.SetSubject("Sending email from Go!")
file, err := os.Open("funny.jpg")
msg.AddAttachment("funny.jpg", file, "")
file.Close()
err = msg.SetBody("This is the text email body.")
err = msg.SetBodyHTML("This is the HTML email body.")
// Send email
err = svc.Send(msg)
log.Println("Successfully sent email via AWS SES.")
}
Index ¶
Examples ¶
Variables ¶
var DefaultMailConfig = MailConfig{ Region: "us-east-1", }
DefaultMailConfig The default config values to use.
Types ¶
type MailConfig ¶
type MailConfig struct { // AWS Region to use // Defaults to us-east-1 Region string // Set Credentials to use a different way to load AWS creds. // For example, env vars or ~/.aws/credentials file // See https://docs.aws.amazon.com/sdk-for-go/api/ for more info Credentials *credentials.Credentials // AWS Access Key // Required if no Credentials are set AccessID string // AWS Secret Key // Required if no Credentials are set SecretKey string }
MailConfig is the configuration for SMTP connection and sending
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service Direct delivery via AWS SES connection
func NewSESService ¶
func NewSESService(mc *MailConfig) (*Service, error)
NewSESService Returns an SES service instance
func (*Service) Send ¶
Send Sends an email from the given *carrier.Message object
Source Files ¶
ses.go
- Version
- v0.0.0-20250114214955-7f5d9b835a85 (latest)
- Published
- Jan 14, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 1 month ago –
Tools for package owners.