Skip to main content
Infidec Marketplace logo
v1.0.0

Type to search pages and sections, e.g. “razorpay”, “package name”, “SHA”.

Email Templates & SMTP

Manage the email templates (code, subject, HTML body, variables) and what you need to add to actually send email, since the backend has no SMTP or email provider built in.

Admin → Settings → Email Templates stores the text of the emails your platform sends. Data: the Firestore email_templates collection (/admin/crud/email_templates).

Email Templates
Settings → Email Templates

The list

ColumnShows
CodeTemplate code, e.g. welcome (sortable)
SubjectSubject line, e.g. Welcome to {{ app_name }}!
ActiveToggle
ActionEdit, Delete

Search... covers code and subject. Export CSV downloads email_templates.csv. Templates are sorted by code.

Create or edit a template

Click Create Template:

FieldNotes
CodeRequired and unique, e.g. welcome. Your sending code looks the template up by this
SubjectRequired. May contain placeholders
BodyRequired. Rich-text editor; saved as HTML (body_html)
VariablesTags. "Placeholders available in this template, e.g. name, link". A note for editors; it does not change the template

Placeholders use the {{ name }} style shown in the demo templates. Replacing them is up to your sending code.

Add email sending

The simplest option on Firebase is the official Trigger Email from Firestore extension, or a small function that calls your provider (SMTP, SendGrid, Mailgun, Amazon SES…).

  1. Pick a provider and keep its key secret

    Store the SMTP password or API key in Secret Manager, for example firebase functions:secrets:set SMTP_PASSWORD. Do not put it in functions/.env or in the Admin Panel.

  2. Write a helper

    Add a function such as sendTemplate(code, to, vars) in functions/src/lib/. It reads email_templates where code == … and is_active != false, replaces {{ key }} in subject and body_html with vars, and sends the email. Check setting("notifications", "email_enabled") first so the admin switch works.

  3. Call it where you need email

    Good places are next to the existing notify() calls: ad approved (functions/src/routes/admin/index.ts), payment completed (fulfil() in functions/src/routes/billing.ts), and OTP delivery for the email channel (sendOtp() in functions/src/lib/otp.ts, see OTP delivery).

  4. Deploy

    Add the secret to the function's secrets list and redeploy the functions (see Deploy the Backend).

Next: Firebase Settings →

Something unclear or out of date? Tell us. contact@infidec.com