The Mail module handles all outbound email delivery for Kantuta POS. It exposes a single public REST endpoint for sending ad-hoc messages and powers four Handlebars-rendered HTML templates that are triggered automatically by other modules — welcome confirmations, password reset codes, and post-change security alerts. All email delivery is handled exclusively by Resend (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt
Use this file to discover all available pages before exploring further.
resend.emails.send()), configured via RESEND_API_KEY. The @nestjs-modules/mailer SMTP transport is present in the module configuration but is not called at runtime by any MailService method.
Send a generic email
POST /mail
generic-message.hbs Handlebars template. This endpoint is public — no Authorization header is required.
Request body
Recipient email address. Must be a valid RFC-5321 address (e.g.
[email protected]).Email subject line displayed in the recipient’s inbox.
Body content of the email in plain text. Rendered inside the
generic-message.hbs template.Recipient display name used in the greeting inside the email template.
Response
Returns a JSON object confirming delivery and the Resend message ID.Human-readable confirmation —
"Correo enviado correctamente".Unique message ID assigned by the Resend API (e.g.
"re_123abc..."). Use this to track delivery status in your Resend dashboard.Example
Email templates
All emails are rendered with Handlebars (@nestjs-modules/mailer + HandlebarsAdapter). Templates live in src/mail/templates/ and share two reusable Handlebars partials — {{> header}} and {{> footer}} — from src/mail/templates/partials/.
| Template file | Trigger | Variables injected |
|---|---|---|
welcome.hbs | New user registration (via Auth module) | name, year |
reset-code.hbs | Password reset code request (POST /auth/reset/code) | code, name, date |
password-changed.hbs | Successful password change | name, date |
generic-message.hbs | POST /mail (this endpoint) | message, name, date |
welcome.hbs
Sent automatically when a new user account is created. Greets the user by name and includes the current year in the footer copyright. No developer action required — the Auth module calls MailService.sendWelcome() internally.
reset-code.hbs
Delivers a short numeric code for password reset flows. Triggered by POST /auth/reset/code, not by calling /mail directly. The code, recipient name, and issue date are interpolated at send time.
password-changed.hbs
A security confirmation dispatched after a successful password update. Contains the recipient’s name and the local date of the change so the user can identify unauthorized activity.
generic-message.hbs
The template consumed by POST /mail. Wraps any arbitrary plain-text message with the standard branded header and footer, addressed to name.
Transport configuration
All
MailService methods call resend.emails.send() directly using the Resend SDK. The MailerModule SMTP transport (configured with EMAIL_HOST, EMAIL_PORT, EMAIL_USER, EMAIL_PASSWORD, and EMAIL_SECURE) is wired into the module but is not invoked by any service method — it is legacy infrastructure and has no effect on sent emails.| Variable | Description |
|---|---|
RESEND_API_KEY | API key from resend.com — primary transport |
EMAIL_HOST | SMTP host (fallback / mailer module config) |
EMAIL_PORT | SMTP port (e.g. 587) |
EMAIL_USER | SMTP auth username |
EMAIL_PASSWORD | SMTP auth password |
EMAIL_SECURE | "true" for TLS on port 465, "false" for STARTTLS |
EMAIL_REJECT_UNAUTHORIZED | "true" to enforce strict TLS cert validation |
Password reset emails are sent automatically by
POST /auth/reset/code — you do not need to call POST /mail to trigger them. Similarly, welcome and password-changed emails are fired by the Auth module without any additional API call.