Documentation ¶
Overview ¶
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" json:"-"` // ignored by zap's JSON formatter 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) From ¶ added in v0.12.1
func (s *NoopProvider) From() string
From returns who the invitation should be send from.
type Provider ¶
type Provider interface { // SendEmail sends an email with the given message. SendEmail(ctx context.Context, toEmail string, message []byte) error // From returns who shown as the sender of the email. From() string }
Provider is an interface for email-sending mechanisms.
type ProviderType ¶
type ProviderType string
ProviderType represents a type of email provider.
const ( // ProviderTypeNoop is a no-op provider ProviderTypeNoop ProviderType = "NOOP" // ProviderTypeSMTP composes emails and sends them via an external SMTP server. ProviderTypeSMTP ProviderType = "SIMPLE_SMTP" )
type SMTPProvider ¶
SMTPProvider sends messages via an external SMTP server.
func (*SMTPProvider) From ¶ added in v0.12.1
func (s *SMTPProvider) From() string
From returns who shown as the sender of the email.