Documentation
¶
Index ¶
- func Send(m *Message) error
- type Attachment
- type Driver
- type MailgunAPIDriver
- type MailgunSMTPDriver
- type Message
- func (m *Message) AddBcc(bcc ...string) *Message
- func (m *Message) AddCc(cc ...string) *Message
- func (m *Message) AllRecipients() []string
- func (m *Message) Attach(filename string, data []byte, mimeType ...string) *Message
- func (m *Message) SetBody(body string, html bool) *Message
- func (m *Message) SetFrom(from string) *Message
- func (m *Message) SetReplyTo(replyTo string) *Message
- func (m *Message) SetTo(to ...string) *Message
- type PostmarkDriver
- type ResendDriver
- type SESAPIDriver
- type SESDriver
- type SMTPDriver
- type SendGridDriver
- type SendGridSMTPDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
type Attachment struct {
Filename string
Data []byte
MIMEType string // e.g. "application/pdf". Auto-detected if empty.
}
Attachment represents a file attachment on an email.
type MailgunAPIDriver ¶
type MailgunAPIDriver struct {
Domain string
APIKey string
FromAddr string
Endpoint string // defaults to "https://api.mailgun.net/v3"
Client *http.Client
}
MailgunAPIDriver sends email via the Mailgun HTTP API. This is a native API driver — no SMTP connection required.
driver := mail.NewMailgunAPIDriver("your-domain.com", "key-xxx", "sender@your-domain.com")
mail.Default = driver
func NewMailgunAPIDriver ¶
func NewMailgunAPIDriver(domain, apiKey, fromAddr string) *MailgunAPIDriver
NewMailgunAPIDriver creates a Mailgun API driver.
func (*MailgunAPIDriver) Send ¶
func (d *MailgunAPIDriver) Send(m *Message) error
Send sends the message via Mailgun's API.
type MailgunSMTPDriver ¶
type MailgunSMTPDriver struct {
// contains filtered or unexported fields
}
MailgunSMTPDriver wraps SMTPDriver for Mailgun SMTP transport. For the native API driver, use MailgunAPIDriver instead. Example addr: "smtp.mailgun.org:587".
func NewMailgunSMTPDriver ¶
func NewMailgunSMTPDriver(addr string, auth smtp.Auth, fromAddr string) *MailgunSMTPDriver
func (*MailgunSMTPDriver) Send ¶
func (d *MailgunSMTPDriver) Send(m *Message) error
type Message ¶
type Message struct {
From string
To []string
Cc []string
Bcc []string
ReplyTo string
Subject string
Body string
HTML bool
Attachments []Attachment
}
Message represents an email (plan: mail drivers SMTP, etc.).
func NewMessage ¶
NewMessage creates a new Message with the given subject.
func (*Message) AllRecipients ¶
AllRecipients returns To + Cc + Bcc for envelope delivery.
func (*Message) SetReplyTo ¶
SetReplyTo sets the reply-to address.
type PostmarkDriver ¶
type PostmarkDriver struct {
// contains filtered or unexported fields
}
PostmarkDriver wraps SMTPDriver for Postmark. Example addr: "smtp.postmarkapp.com:587".
func NewPostmarkDriver ¶
func NewPostmarkDriver(addr string, auth smtp.Auth, fromAddr string) *PostmarkDriver
func (*PostmarkDriver) Send ¶
func (d *PostmarkDriver) Send(m *Message) error
type ResendDriver ¶
ResendDriver sends email via the Resend HTTP API.
driver := mail.NewResendDriver("re_xxxx", "sender@example.com")
mail.Default = driver
func NewResendDriver ¶
func NewResendDriver(apiKey, fromAddr string) *ResendDriver
NewResendDriver creates a Resend API driver.
func (*ResendDriver) Send ¶
func (d *ResendDriver) Send(m *Message) error
Send sends the message via Resend's API.
type SESAPIDriver ¶
type SESAPIDriver struct {
Region string
AccessKey string
SecretKey string
FromAddr string
Client *http.Client
}
SESAPIDriver sends email via the Amazon SES v2 HTTP API using AWS Signature Version 4. For simplicity, this driver uses the SES SendEmail Action via query parameters (no external AWS SDK required).
driver := mail.NewSESAPIDriver("us-east-1", "AKID...", "secret...", "sender@example.com")
mail.Default = driver
func NewSESAPIDriver ¶
func NewSESAPIDriver(region, accessKey, secretKey, fromAddr string) *SESAPIDriver
NewSESAPIDriver creates an SES API driver (no SDK required).
func (*SESAPIDriver) Send ¶
func (d *SESAPIDriver) Send(m *Message) error
Send sends the message via SES API. It builds a raw MIME message and sends it via the SES SendRawEmail action.
type SESDriver ¶
type SESDriver struct {
// contains filtered or unexported fields
}
SESDriver is a thin wrapper around SMTPDriver configured for Amazon SES SMTP. Use the SMTP credentials from your SES console.
func NewSESDriver ¶
NewSESDriver creates an SES driver. Example addr: "email-smtp.us-east-1.amazonaws.com:587".
type SMTPDriver ¶
SMTPDriver sends via SMTP.
func NewSMTPDriver ¶
func NewSMTPDriver(addr string, auth smtp.Auth, fromAddr string) *SMTPDriver
NewSMTPDriver returns an SMTP driver. auth can be nil for no auth.
func (*SMTPDriver) Send ¶
func (d *SMTPDriver) Send(m *Message) error
Send sends the message via SMTP.
type SendGridDriver ¶
type SendGridDriver struct {
APIKey string
FromAddr string
FromName string
Endpoint string // defaults to "https://api.sendgrid.com/v3/mail/send"
Client *http.Client
}
SendGridDriver sends email via the SendGrid v3 HTTP API. This is a native API driver — no SMTP connection required.
driver := mail.NewSendGridDriver("SG.your-api-key", "sender@example.com")
mail.Default = driver
func NewSendGridDriver ¶
func NewSendGridDriver(apiKey, fromAddr string) *SendGridDriver
NewSendGridDriver creates a SendGrid API driver.
func (*SendGridDriver) Send ¶
func (d *SendGridDriver) Send(m *Message) error
Send sends the message via SendGrid's v3 API.
type SendGridSMTPDriver ¶
type SendGridSMTPDriver struct {
// contains filtered or unexported fields
}
SendGridSMTPDriver wraps SMTPDriver for SendGrid SMTP transport. For the native API driver, use SendGridDriver instead. Example addr: "smtp.sendgrid.net:587".
func NewSendGridSMTPDriver ¶
func NewSendGridSMTPDriver(addr string, auth smtp.Auth, fromAddr string) *SendGridSMTPDriver
func (*SendGridSMTPDriver) Send ¶
func (d *SendGridSMTPDriver) Send(m *Message) error