Documentation
¶
Overview ¶
Package smtp delivers AuthKit's email through any SMTP server, so the provider is configuration: SendGrid (smtp.sendgrid.net, username "apikey", an API key as the password), ZeptoMail, SES or a server of your own.
email, err := smtp.New(smtp.Config{
Server: smtp.Server{
Host: os.Getenv("EMAIL_SMTP_HOST"),
Port: 587,
Username: os.Getenv("EMAIL_SMTP_USERNAME"),
Password: os.Getenv("EMAIL_SMTP_PASSWORD"),
From: "MyApp <hello@myapp.com>",
},
AppName: "MyApp",
})
if err != nil {
return err
}
deps := authkit.Deps{Postgres: db, Email: email}
Each message kind renders from a built-in template in the message's Language (Spanish for "es", else English). Set Render to supply your own content for some kinds; returning false falls back to the built-in one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Server Server
// AppName names the app in the built-in copy (default "Auth").
AppName string
// Render returns the content for msg, or false to use the built-in
// template for msg.Kind.
Render func(ctx context.Context, msg iam.EmailMessage) (Content, bool)
}
Config configures New. Server.Host and Server.From are required.
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email is an authkit.EmailSender: wire it as authkit.Deps.Email.
func (*Email) CheckHealth ¶
CheckHealth connects, negotiates TLS and authenticates without sending: an error when the server is unreachable or refuses the credentials.