SendRecordAuthAlert (mails/record.go)

pocketbase · mails/record.go · go · MIT
email

Sends authentication related emails (alerts, OTP, password reset, verification) using PocketBase's mail system.

// Source: https://github.com/pocketbase/pocketbase | License: MIT | Copyright 2022 - present, Gani Georgiev
// Provided via justclaw.it.com; keep this notice with the code.
package mails

import (
	"html"
	"html/template"
	"net/mail"
	"slices"

	"github.com/pocketbase/pocketbase/core"
	"github.com/pocketbase/pocketbase/mails/templates"
	"github.com/pocketbase/pocketbase/tools/mailer"
)

// SendRecordAuthAlert sends a new device login alert to the specified auth record.
func SendRecordAuthAlert(app core.App, authRecord *core.Record, info string) error {
	mailClient := app.NewMailClient()

	info = html.EscapeString(info)

	subject, body, err := resolveEmailTemplate(app, authRecord, authRecord.Collection().AuthAlert.EmailTemplate, map[string]any{
		core.EmailPlaceholderAlertInfo: info,
	})
	

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key