Skip to main content
PocketBase provides a mailer interface for sending emails using SMTP or Sendmail.

Creating mail clients

NewMailClient()

Create a mail client based on current app settings:
The mailer is automatically configured based on your app’s email settings (configured via the Admin UI).

Sending emails

Basic email

Email with text alternative

Multiple recipients

Email attachments

Add file attachments

Multiple attachments

Inline attachments (embedded images)

Inline attachments can be referenced in HTML using cid:filename where filename matches the key in InlineAttachments.

Custom headers

Add custom email headers:

Email templates

Using Go templates

Using PocketBase templates

Intercepting emails

OnMailerSend hook

Intercept all outgoing emails:

Modify emails before sending

Block emails in development

OnMailerRecordVerificationSend

Intercept verification emails:

OnMailerRecordPasswordResetSend

Intercept password reset emails:

OnMailerRecordEmailChangeSend

Intercept email change confirmation emails:

OnMailerRecordAuthAlertSend

Intercept auth alert emails (new login notifications):

Sending custom emails from hooks

Welcome email on user registration

Notification on record creation

HTML to text conversion

PocketBase can automatically convert HTML to plain text:

Message type signature

Best practices

Always provide text alternative

Handle errors gracefully

Use templates for consistency

Respect email preferences