Skip to main content

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.

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 (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
Delivers a plain-text message to any recipient using the generic-message.hbs Handlebars template. This endpoint is public — no Authorization header is required.

Request body

email
string
required
Recipient email address. Must be a valid RFC-5321 address (e.g. [email protected]).
subject
string
required
Email subject line displayed in the recipient’s inbox.
message
string
required
Body content of the email in plain text. Rendered inside the generic-message.hbs template.
name
string
required
Recipient display name used in the greeting inside the email template.

Response

Returns a JSON object confirming delivery and the Resend message ID.
message
string
Human-readable confirmation — "Correo enviado correctamente".
id
string
Unique message ID assigned by the Resend API (e.g. "re_123abc..."). Use this to track delivery status in your Resend dashboard.

Example

curl -X POST https://api.kantutapos.com/api/mail \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "subject": "Tu pedido ha sido procesado",
    "message": "Estimado cliente, su pedido #1042 fue procesado exitosamente.",
    "name": "Carlos Mamani"
  }'
{
  "message": "Correo enviado correctamente",
  "id": "re_9XkLmN3p_AbCdEfGhIjKlMnOp"
}

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 fileTriggerVariables injected
welcome.hbsNew user registration (via Auth module)name, year
reset-code.hbsPassword reset code request (POST /auth/reset/code)code, name, date
password-changed.hbsSuccessful password changename, date
generic-message.hbsPOST /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.
Set the following environment variables in your deployment platform (e.g. Render):
VariableDescription
RESEND_API_KEYAPI key from resend.com — primary transport
EMAIL_HOSTSMTP host (fallback / mailer module config)
EMAIL_PORTSMTP port (e.g. 587)
EMAIL_USERSMTP auth username
EMAIL_PASSWORDSMTP 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.

Build docs developers (and LLMs) love