MCPcopy
hub / github.com/pocketbase/pocketbase / SendRecordVerification

Function SendRecordVerification

mails/record.go:166–201  ·  view source on GitHub ↗

SendRecordVerification sends a verification request email to the specified auth record.

(app core.App, authRecord *core.Record)

Source from the content-addressed store, hash-verified

164
165// SendRecordVerification sends a verification request email to the specified auth record.
166func SendRecordVerification(app core.App, authRecord *core.Record) error {
167 token, tokenErr := authRecord.NewVerificationToken()
168 if tokenErr != nil {
169 return tokenErr
170 }
171
172 mailClient := app.NewMailClient()
173
174 subject, body, err := resolveEmailTemplate(app, authRecord, authRecord.Collection().VerificationTemplate, map[string]any{
175 core.EmailPlaceholderToken: token,
176 })
177 if err != nil {
178 return err
179 }
180
181 message := &mailer.Message{
182 From: mail.Address{
183 Name: app.Settings().Meta.SenderName,
184 Address: app.Settings().Meta.SenderAddress,
185 },
186 To: []mail.Address{{Address: authRecord.Email()}},
187 Subject: subject,
188 HTML: body,
189 }
190
191 event := new(core.MailerRecordEvent)
192 event.App = app
193 event.Mailer = mailClient
194 event.Message = message
195 event.Record = authRecord
196 event.Meta = map[string]any{"token": token}
197
198 return app.OnMailerRecordVerificationSend().Trigger(event, func(e *core.MailerRecordEvent) error {
199 return e.Mailer.Send(e.Message)
200 })
201}
202
203// SendRecordChangeEmail sends a change email confirmation email to the specified auth record.
204func SendRecordChangeEmail(app core.App, authRecord *core.Record, newEmail string) error {

Callers 3

SubmitMethod · 0.92

Calls 9

resolveEmailTemplateFunction · 0.85
NewVerificationTokenMethod · 0.80
CollectionMethod · 0.80
EmailMethod · 0.80
TriggerMethod · 0.80
NewMailClientMethod · 0.65
SettingsMethod · 0.65
SendMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…