MCPcopy
hub / github.com/pocketbase/pocketbase / Submit

Method Submit

forms/test_email_send.go:78–118  ·  view source on GitHub ↗

Submit validates and sends a test email to the form.Email address.

()

Source from the content-addressed store, hash-verified

76
77// Submit validates and sends a test email to the form.Email address.
78func (form *TestEmailSend) Submit() error {
79 if err := form.Validate(); err != nil {
80 return err
81 }
82
83 collectionIdOrName := form.Collection
84 if collectionIdOrName == "" {
85 collectionIdOrName = core.CollectionNameSuperusers
86 }
87
88 collection, err := form.app.FindCollectionByNameOrId(collectionIdOrName)
89 if err != nil {
90 return err
91 }
92
93 record := core.NewRecord(collection)
94 for _, field := range collection.Fields {
95 if field.GetHidden() {
96 continue
97 }
98 record.Set(field.GetName(), "__pb_test_"+field.GetName()+"__")
99 }
100 record.RefreshTokenKey()
101 record.SetEmail(form.Email)
102
103 switch form.Template {
104 case TestTemplateVerification:
105 return mails.SendRecordVerification(form.app, record)
106 case TestTemplatePasswordReset:
107 return mails.SendRecordPasswordReset(form.app, record)
108 case TestTemplateEmailChange:
109 return mails.SendRecordChangeEmail(form.app, record, form.Email)
110 case TestTemplateOTP:
111 return mails.SendRecordOTP(form.app, record, "_PB_TEST_OTP_ID_", "123456")
112 case TestTemplateAuthAlert:
113 testEvent := types.NowDateTime().String() + " - TEST_IP TEST_USER_AGENT"
114 return mails.SendRecordAuthAlert(form.app, record, testEvent)
115 default:
116 return errors.New("unknown template " + form.Template)
117 }
118}

Callers 2

settingsTestEmailFunction · 0.95

Calls 15

ValidateMethod · 0.95
SetMethod · 0.95
RefreshTokenKeyMethod · 0.95
SetEmailMethod · 0.95
NewRecordFunction · 0.92
SendRecordVerificationFunction · 0.92
SendRecordPasswordResetFunction · 0.92
SendRecordChangeEmailFunction · 0.92
SendRecordOTPFunction · 0.92
NowDateTimeFunction · 0.92
SendRecordAuthAlertFunction · 0.92

Tested by 1