mails

package
v0.0.0-...-1746241 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 24 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Mails Service

Responsibility

Canonical home for application mail flows and Gmail mailbox integration: OAuth callback, token storage, label initialization, sync orchestration, message persistence and record-facing transactional emails.

Structure

  • service.go — descriptor and service-level contract.
  • config.go — Google/Gmail configuration resolution.
  • client.go, label.go, message.go — Gmail client, labels and message sync flows.
  • record.go — PocketBase record-facing mail flows.
  • templates/ — HTML mail templates/layouts.
  • models/ — mail sync/message persistence models.
  • apis/ — project mail HTTP bindings.
  • queries/ — reusable DAO/query helpers.
  • forms/ — request/submit DTOs.
  • migrations/ — module-owned mail schema.
  • runtime.go — placeholder for future background sync runtime/caches.

Dependencies

  • core.App
  • services/base/models for OAuth tokens
  • tools/mailer, tools/tokens
  • Google OAuth/Gmail API client packages

Public flows

  • Compose and send record-facing emails.
  • Render HTML templates/layouts.
  • Start Gmail OAuth flow and persist Gmail token.
  • Initialize labels and sync Gmail messages.
  • Expose sync status and inactive syncs for re-auth flows.

Migration notes

Mail sync and mail message tables are registered from services/mails/migrations through migrations/dbase/mails_module.go.

Documentation

Overview

Package mails implements various helper methods for sending user and admin emails like forgotten password, verification, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendRecordChangeEmail

func SendRecordChangeEmail(app core.App, record *recordmodels.Record, newEmail string) error

SendRecordChangeEmail sends a change email confirmation email to the specified user.

func SendRecordPasswordLoginAlert

func SendRecordPasswordLoginAlert(app core.App, authRecord *recordmodels.Record, providerNames ...string) error

SendRecordPasswordLoginAlert sends an OAuth2 password login alert to the specified auth record.

func SendRecordPasswordReset

func SendRecordPasswordReset(app core.App, authRecord *recordmodels.Record) error

SendRecordPasswordReset sends a password reset request email to the specified user.

func SendRecordVerification

func SendRecordVerification(app core.App, authRecord *recordmodels.Record) error

SendRecordVerification sends a verification request email to the specified user.

Types

type MailService

type MailService struct {
	// contains filtered or unexported fields
}

MailService handles Gmail integration and operations

func NewMailService

func NewMailService() *MailService

NewMailService creates a new MailService instance with configuration from environment variables

func NewMailServiceWithApp

func NewMailServiceWithApp(app core.App) *MailService

func (*MailService) FetchClient

func (ms *MailService) FetchClient(ctx context.Context, tokenId string) (*http.Client, error)

FetchClient retrieves an authenticated HTTP client for a given token ID.

func (*MailService) GetAuthUrl

func (ms *MailService) GetAuthUrl() string

GetAuthUrl generates an OAuth authorization URL for Gmail authentication

func (*MailService) GetConfig

func (ms *MailService) GetConfig() *oauth2.Config

GetConfig returns the OAuth2 configuration

func (*MailService) GetGmailService

func (ms *MailService) GetGmailService(ctx context.Context, client *http.Client) (*gmail.Service, error)

GetGmailService creates a Gmail API service client using the provided HTTP client.

type MailServiceConfig

type MailServiceConfig struct {
	ClientID     string
	ClientSecret string
	RedirectURL  string
}

func ConfigFromEnv

func ConfigFromEnv() MailServiceConfig

func ConfigFromSettings

func ConfigFromSettings(app core.App) MailServiceConfig

func ConfigFromSettingsModel

func ConfigFromSettingsModel(settings settingsmodels.MailConfig) MailServiceConfig

func DefaultConfig

func DefaultConfig() MailServiceConfig

func ResolveConfig

func ResolveConfig(app core.App) MailServiceConfig

type Message

type Message struct {
	*mailer.Message
}

func NewMessage

func NewMessage() *Message

func (*Message) RenderHTML

func (m *Message) RenderHTML(raw string, data any) error

func (*Message) RenderText

func (m *Message) RenderText(raw string, data any) error

type Runtime

type Runtime struct{}

Runtime holds mutable mails-related state.

The module currently mostly contains integration helpers and templates. Runtime is kept as a placeholder for future background sync and caches.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles transactional emails.

func New

func New(app core.App) *Service

New creates new mails service instance.

func (*Service) SendRecordChangeEmail

func (s *Service) SendRecordChangeEmail(record *recordmodels.Record, newEmail string) error

SendRecordChangeEmail sends a change email confirmation email to the specified user.

func (*Service) SendRecordPasswordLoginAlert

func (s *Service) SendRecordPasswordLoginAlert(authRecord *recordmodels.Record, providerNames ...string) error

SendRecordPasswordLoginAlert sends an OAuth2 password login alert to the specified auth record.

func (*Service) SendRecordPasswordReset

func (s *Service) SendRecordPasswordReset(authRecord *recordmodels.Record) error

SendRecordPasswordReset sends a password reset request email to the specified user.

func (*Service) SendRecordVerification

func (s *Service) SendRecordVerification(authRecord *recordmodels.Record) error

SendRecordVerification sends a verification request email to the specified user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL