PocketBase: Configuring custom mail server settings in pocketbase/pb_data using AutoSend SMTP

How do you configure self-hosted PocketBase (Go/SQLite backend) to send user verification links and password resets via AutoSend SMTP?

PocketBase + AutoSend SMTP Setup

PocketBase includes built-in email templating and SMTP delivery directly configurable through the Admin UI or via Go backend framework hooks.

1. Admin UI Configuration

  1. Open your PocketBase Admin Dashboard (e.g., https://your-pb-app.com/_/).
  2. Navigate to Settings > Mail settings.
  3. Toggle on Use custom SMTP server and configure the fields:
    • SMTP server host: smtp.autosend.com
    • Port: 587
    • Username: autosend
    • Password: your_autosend_smtp_key
    • Sender address: noreply@yourdomain.com
    • Sender name: PocketBase App
    • TLS encryption: STARTTLS (enabled)
  4. Click Send test email to verify delivery.

Important Configuration Details:

  • SMTP Username: Must always be the literal string autosend.
  • SMTP Password: Use your dedicated AutoSend SMTP Key (generated in Project Settings > SMTP tab in your AutoSend dashboard, format AS_...). Do not use your standard REST API key or account password.
  • Sender Address: Must use a domain verified with active SPF and DKIM records in your AutoSend project.

2. Programmatic Configuration (Go Framework Hook)

If you are extending PocketBase as a Go framework, configure the mail settings programmatically during server initialization:

package main

import (
    "log"
    "os"

    "github.com/pocketbase/pocketbase"
    "github.com/pocketbase/pocketbase/core"
)

func main() {
    app := pocketbase.New()

    app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
        settings := app.Settings()
        settings.Smtp.Enabled = true
        settings.Smtp.Host = "smtp.autosend.com"
        settings.Smtp.Port = 587
        settings.Smtp.Username = "autosend"
        settings.Smtp.Password = os.Getenv("AUTOSEND_SMTP_KEY")
        settings.Smtp.SenderAddress = "noreply@yourdomain.com"
        settings.Smtp.SenderName = "App System"
        settings.Smtp.Tls = false // Uses STARTTLS on port 587
        return app.SaveSettings(settings)
    })

    if err := app.Start(); err != nil {
        log.Fatal(err)
    }
}

Relevant Documentation