Email Notifications

Email notifications are sent for key account and organization events. Each notification uses a customizable template that can be edited from the admin panel.

Notification Classes

The following notifications are delivered via email:

  • WelcomeNotification — sent after registration
  • MfaStatusNotification — sent when MFA is enabled or disabled
  • ApiKeyCreatedNotification — sent when a new API key is generated
  • InvitationNotification — sent to invited users with a join link
  • MemberJoinedNotification — sent to org admins when a new member joins
  • PasswordChangedNotification — sent when the user changes their password
  • PaymentFailedNotification — sent when a Stripe payment fails
  • SubscriptionActivatedNotification — sent when a subscription starts or renews
  • SubscriptionCancelledNotification — sent when a subscription is cancelled

UsesEmailTemplate Trait

All email notifications use the UsesEmailTemplate trait. This trait:

  • Loads the corresponding EmailTemplate record from the database by template slug
  • Renders the template body with variable substitution (e.g. {name}, {org_name})
  • Falls back to a default template if no custom template exists
class WelcomeNotification extends Notification
{
    use UsesEmailTemplate;

    protected $templateSlug = 'welcome';

    public function toMail($notifiable)
    {
        return $this->buildMailFromTemplate($notifiable, [
            'name' => $notifiable->name,
            'email' => $notifiable->email,
        ]);
    }
}

TemplateMail Class

The TemplateMail class is a Mailable that renders the final email using the template's subject, body, and layout. It handles variable interpolation and wraps the content in the application's email layout.

Mail Drivers

LaunchKit supports multiple mail drivers, switchable from the admin panel without code changes:

  • SMTP — standard SMTP server
  • Mailgun — via Mailgun API
  • Postmark — via Postmark API
  • Resend — via Resend API
  • SES — via Amazon Simple Email Service

MailConfigService

The MailConfigService loads mail configuration from the database at runtime, allowing admins to change the mail driver, credentials, and sender details without editing .env or config files. Settings are applied on each request via the service provider.