Eme2App can send invoices, quotes, and delivery notes (albaranes) directly by email from the document detail view, attaching the generated PDF automatically. Email delivery is powered by Nodemailer and uses SMTP credentials stored in your company profile. Four providers are supported out of the box — Gmail, Outlook, Brevo (formerly Sendinblue), and any generic custom SMTP server — and the configuration can be tested without leaving the settings screen. Every document send route reuses the same SMTP transport as the test endpoint, so confirming your credentials work in the test step guarantees they will work for real document sends.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eme2dev/Eme2App/llms.txt
Use this file to discover all available pages before exploring further.
How it works
empresa record. When an email is sent from a document endpoint, Eme2App fetches the active empresa’s SMTP configuration automatically from the JWT context — no extra parameters are needed in the document send request.
Authentication and roles
SMTP configuration is part of the company profile and requires:- A valid JWT bearer token in the
Authorizationheader. - Role
admin— only admins can read or write SMTP settings and trigger the test endpoint. - Document send endpoints (
/api/facturas/:id/enviar-email, etc.) require roleadminoruserwith an active empresa.
Configuring SMTP
SMTP fields are set viaPUT /api/empresa (full company profile update). The relevant fields are:
| Field | Type | Description |
|---|---|---|
smtp_provider | string | One of gmail, outlook, brevo, custom |
smtp_host | string | SMTP server hostname. Required for brevo and custom; ignored for gmail/outlook (Nodemailer resolves these by service name). |
smtp_port | integer | SMTP port (1–65535). Defaults to 587 if not specified. |
smtp_secure | boolean | true for implicit TLS (port 465). false uses STARTTLS. Port 465 always forces true. |
smtp_user | string | SMTP username / login email address. |
smtp_pass | string | SMTP password or App Password. |
email_from | string | Sender display name or From address. Accepts a plain name ("Mi Empresa") or a full RFC 822 address ("Mi Empresa <facturas@miempresa.com>"). Falls back to smtp_user if empty. |
Example request
Provider configuration
- Gmail
- Outlook / Microsoft 365
- Brevo (Sendinblue)
- Custom SMTP
Gmail requires an App Password — a 16-character code generated in your Google Account security settings. Using your regular Google account password will fail because Google blocks third-party SMTP logins from accounts with 2-Step Verification enabled.When
smtp_provider is gmail, Eme2App passes the value directly to Nodemailer’s service: 'gmail' option, which configures smtp.gmail.com:587 with STARTTLS automatically — you do not need to set smtp_host or smtp_port.Testing the configuration
Before saving final credentials, test the connection and delivery withPOST /api/empresa/probar-email. This endpoint creates a transient Nodemailer transport from the fields you pass in the request body — it does not require the settings to be saved in the empresa record first, making it safe to test before committing.
Required role: admin
Request body
| Field | Type | Required | Description |
|---|---|---|---|
destino | string | ✅ Yes | Recipient email address for the test message. |
smtp_provider | string | No | Provider to test (gmail, outlook, brevo, custom). |
smtp_host | string | No | SMTP host (required for brevo/custom). |
smtp_port | integer | No | SMTP port. |
smtp_secure | boolean | No | TLS mode. |
smtp_user | string | No | SMTP username. |
smtp_pass | string | No | SMTP password or App Password. |
email_from | string | No | Sender address for the test message. |
Example
Success response
Error response
Sending documents by email
Once SMTP is configured in the empresa profile, documents can be sent by email from their respective API endpoints. Each endpoint generates the PDF on the server, attaches it to the email, and delivers it using the empresa’s saved SMTP settings.Invoice
POST /api/facturas/:id/enviar-emailQuote
POST /api/presupuestos/:id/enviar-emailDelivery note
POST /api/albaranes/:id/enviar-emailadmin or user.
The :id parameter is the UUID of the document in the database. Eme2App fetches the document, generates the PDF, looks up the recipient email from the associated cliente record, and sends the message using the empresa’s SMTP configuration — no additional body parameters are required.
Invoice email example
SMTP error reference
| Error message pattern | Cause and fix |
|---|---|
Autenticacion SMTP fallida... App Password | Wrong password. For Gmail, use an App Password, not the account password. |
Falta usuario o contraseña SMTP | smtp_user or smtp_pass is empty in the empresa profile. |
Falta SMTP_HOST en la configuración | smtp_host is required for brevo and custom providers. |
No se pudo conectar al servidor SMTP... puertos 25, 465 y 587 | Hosting provider blocks outbound SMTP ports. Use Brevo on port 2525 or upgrade hosting plan. |
Error SMTP: <server response> | The SMTP server returned an error. The full server response is included in the message. |