Documentation
¶
Overview ¶
Package email is logic for sending email invitations
Package email is logic for sending email invitations ¶
Package email is logic for sending email invitations
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ProviderType ProviderType
User string `env:"EMAIL_USER"`
Password string `env:"EMAIL_PASSWORD"`
SMTPHost string `env:"EMAIL_SMTP_HOST"`
// SMTPPort defines the email port to connect to.
// Note: legacy email port 25 is blocked on GCP and many other systems.
SMTPPort string `env:"EMAIL_SMTP_PORT, default=587"`
// Secrets is the secret configuration. This is used to resolve values that
// are actually pointers to secrets before returning them to the caller. The
// table implementation is the source of truth for which values are secrets
// and which are plaintext.
Secrets secrets.Config
}
Config represents the env var based configuration for email SMTP server connection.
Note: This will only work with email providers that accept external connections.
The provider must accept TLS, and users should independently consider the security
of the email provider / account.
Gmail or Google Workspace accounts can be used with an app-password, but will
not work with security features such as Advanced Protection enabled.
func (*Config) HasSMTPCreds ¶
HasSMTPCreds returns true if required fields for connecting to SMTP are set.
type NoopProvider ¶
type NoopProvider struct{}
NoopProvider is an email sender that logs without taking any actions.
func (*NoopProvider) SendNewUserInvitation ¶
func (s *NoopProvider) SendNewUserInvitation(ctx context.Context, toEmail string) error
SendNewUserInvitation sends a password reset email to the user.
type Provider ¶
type Provider interface {
// SendNewUserInvitation sends an invite to join the server.
SendNewUserInvitation(ctx context.Context, email string) error
}
Provider is an interface for email-sending mechanisms.
func NewFirebase ¶
NewFirebase creates a new SMTP email sender with the given auth.
type ProviderType ¶
type ProviderType string
ProviderType represents a type of email provider.
const ( // ProviderTypeNoop is a no-op provider ProviderTypeNoop ProviderType = "NOOP" // ProviderTypeFirebase falls back to firebase's default email template. // it uses password-reset rather than a true invitation. ProviderTypeFirebase ProviderType = "FIREBASE" // ProviderTypeSMTP composes emails and sends them via an external SMTP server. ProviderTypeSMTP ProviderType = "SIMPLE_SMTP" )
type SMTPProvider ¶
type SMTPProvider struct {
FirebaseAuth *auth.Client
Renderer *render.Renderer
User string
Password string
SMTPHost string
SMTPPort string
}
SMTPProvider sends messages via an external SMTP server.
func (*SMTPProvider) SendNewUserInvitation ¶
func (s *SMTPProvider) SendNewUserInvitation(ctx context.Context, toEmail string) error
SendNewUserInvitation sends a password reset email to the user.