Documentation
¶
Overview ¶
contract.go: Wires the email plugin into the forge-dashboard contract surface. The manifest + handlers live in the subpackage at plugins/email/contract/; this file exposes the integration via plugin.ContractContributor so authsome's RegisterContractContributor loop picks the plugin up automatically.
Package email provides transactional email notifications for AuthSome.
The email plugin listens to auth lifecycle events (sign-up, user creation, password reset, invitation) and sends contextual transactional emails via the bridge.Mailer interface. No SMTP logic lives here — the plugin delegates all delivery to whatever Mailer implementation the host app configures.
Usage:
eng, _ := authsome.NewEngine(
authsome.WithStore(store),
authsome.WithMailer(myMailer),
authsome.WithPlugin(email.New(email.Config{
From: "noreply@example.com",
AppName: "My App",
BaseURL: "https://example.com",
})),
)
Index ¶
- Variables
- func InvitationEmail(inviterName, orgName, appName, acceptURL string) (subject, html, text string)
- func PasswordResetEmail(name, appName, resetURL string) (subject, html, text string)
- func VerificationEmail(name, appName, verifyURL string) (subject, html, text string)
- func WelcomeEmail(name, appName string) (subject, html, text string)
- type Config
- type Plugin
- func (p *Plugin) DeclareSettings(m *settings.Manager) error
- func (p *Plugin) Name() string
- func (p *Plugin) OnAfterSignUp(ctx context.Context, u *user.User, _ *session.Session) error
- func (p *Plugin) OnAfterUserCreate(ctx context.Context, u *user.User) error
- func (p *Plugin) OnInit(_ context.Context, engine plugin.Engine) error
- func (p *Plugin) RegisterContract(d *dispatcher.Dispatcher, reg contract.Registry, wreg contract.WardenRegistry, ...) error
- func (p *Plugin) SendInvitation(ctx context.Context, email, inviterName, orgName, acceptURL string) error
- func (p *Plugin) SendPasswordReset(ctx context.Context, email, name, resetURL string) error
- func (p *Plugin) SetMailer(m bridge.Mailer)
Constants ¶
This section is empty.
Variables ¶
var ( // SettingFromAddress controls the default sender email address. SettingFromAddress = settings.Define("email.from_address", "noreply@authsome.local", settings.WithDisplayName("From Address"), settings.WithDescription("Default sender email address for outgoing emails"), settings.WithCategory("Email"), settings.WithScopes(settings.ScopeGlobal, settings.ScopeApp), settings.WithInputType(formconfig.FieldEmail), settings.WithPlaceholder("noreply@example.com"), settings.WithHelpText("The sender address shown in outgoing emails"), settings.WithOrder(10), ) // SettingAppName controls the application name used in email templates. SettingAppName = settings.Define("email.app_name", "AuthSome", settings.WithDisplayName("Application Name"), settings.WithDescription("Application name used in email subjects and bodies"), settings.WithCategory("Email"), settings.WithScopes(settings.ScopeGlobal, settings.ScopeApp), settings.WithPlaceholder("My App"), settings.WithHelpText("Used in email templates for branding"), settings.WithOrder(20), ) // SettingBaseURL controls the application root URL for email links. SettingBaseURL = settings.Define("email.base_url", "", settings.WithDisplayName("Base URL"), settings.WithDescription("Application root URL for building links in emails"), settings.WithCategory("Email"), settings.WithScopes(settings.ScopeGlobal, settings.ScopeApp), settings.WithInputType(formconfig.FieldURL), settings.WithPlaceholder("https://example.com"), settings.WithHelpText("Used to build verification and action links in emails"), settings.WithOrder(30), ) )
Functions ¶
func InvitationEmail ¶
InvitationEmail returns an organization invitation email.
func PasswordResetEmail ¶
PasswordResetEmail returns a password reset email.
func VerificationEmail ¶
VerificationEmail returns an email verification message.
func WelcomeEmail ¶
WelcomeEmail returns a welcome email for a newly registered user.
Types ¶
type Config ¶
type Config struct {
// From is the default sender email address (e.g. "noreply@example.com").
From string
// AppName is used in email subjects and bodies (e.g. "My App").
AppName string
// BaseURL is the application root URL for building links in emails
// (e.g. "https://example.com").
BaseURL string
}
Config configures the email notification plugin.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is the email notification plugin.
func (*Plugin) DeclareSettings ¶
DeclareSettings implements plugin.SettingsProvider.
func (*Plugin) OnAfterSignUp ¶
OnAfterSignUp sends a welcome email to the newly registered user.
func (*Plugin) OnAfterUserCreate ¶
OnAfterUserCreate sends a verification email to the newly created user.
func (*Plugin) RegisterContract ¶
func (p *Plugin) RegisterContract( d *dispatcher.Dispatcher, reg contract.Registry, wreg contract.WardenRegistry, engine plugin.Engine, ) error
RegisterContract implements plugin.ContractContributor. Type-asserts the engine handle to *authsome.Engine and delegates to the subpackage.
func (*Plugin) SendInvitation ¶
func (p *Plugin) SendInvitation(ctx context.Context, email, inviterName, orgName, acceptURL string) error
SendInvitation sends an organization invitation email.
func (*Plugin) SendPasswordReset ¶
SendPasswordReset sends a password reset email. This is typically called by the engine's password reset flow.