Overview
The Messaging System provides comprehensive email communication capabilities for associations to communicate with their members. It supports both individual member emails and bulk communications to all active members (socios), with professional HTML email templates and integrated WYSIWYG editing. The system integrates with the member management module to enable targeted communications and uses a professional email template for consistent branding across all communications.Key Functionality
Bulk Messaging
Send emails to all members with “Socio” status in a single operation
Individual Emails
Send targeted emails to specific members from the member list
HTML Editor
Format messages with bold, italic, and hyperlinks using toolbar or HTML tags
Professional Templates
Automatic application of branded email template with logo and footer
User Interface Workflow
Global Messaging Interface (Mensajeria.vue)
The dedicated messaging page provides:-
Header Section:
- Title: “Mensajería Global”
- Icon: mail_lock
- Description: “Este mensaje será enviado a todos los usuarios con estado ‘Socio’”
-
Email Composition Form:
- Subject Input: Text field for email subject line
- Editor Toolbar: Quick formatting buttons for:
- Bold (
<b>tag) - Italic (
<i>tag) - Hyperlink (
<a href>tag)
- Bold (
- Message Textarea: Large text area supporting HTML tags
- Live Preview: Real-time HTML rendering of message content
-
Send Button:
- Disabled when subject or message is empty
- Shows loading state: “Enviando a todos…”
- Requires confirmation before sending
Individual Email (from Member List)
From Usuarios.vue member management:- Click mail icon next to member name
- MailModal opens with pre-populated recipient
- Compose subject and message
- Send email to single member
- Success notification confirms delivery
API Endpoints
All messaging endpoints require JWT authentication withadmin or monitor roles.
POST /mail/send
Send email to specific recipient(s).The
to field accepts both a single email string or an array of email addresses for multi-recipient messages.POST /mail/send-all
Send email to all members with “Socio” status.- If no members have “Socio” status:
Email Template
All emails are automatically wrapped in a professional HTML template:Template Features
-
Header:
- SociApp logo (50px height)
- Brand name with consistent styling
- Light gray background (#f9f9f9)
-
Body:
- Greeting: “Estimado Socio,”
- User message with line break conversion (
\n→<br>) - Responsive padding and line height
-
Footer:
- Auto-reply disclaimer
- Copyright notice with current year
- Centered text with muted colors
Backend Service Implementation
The MailService (mail.service.ts) handles email operations:Key Implementation Details
-
Dependency Injection:
- MailerService from
@nestjs-modules/mailer - Usuarios repository for member queries
- MailerService from
-
Error Handling:
- Try-catch blocks around email operations
- Detailed error logging to console
- Errors propagated to controller for HTTP response
-
Email Filtering:
- Query only members with
socio: 'Socio' - Filter out null/empty email addresses
- Return error if no valid recipients found
- Query only members with
Frontend Implementation
Toolbar Formatting
The editor toolbar applies HTML tags to selected text:<b>- Bold text<i>- Italic text<a href="...">- Hyperlinks (prompts for URL)
Sending Global Email
- Validation: Subject and message required
- Confirmation dialog before sending
- Loading state prevents duplicate sends
- Success/error notifications
- Form reset after successful send
Live Preview
Use Cases
Monthly Newsletter
- Navigate to Mensajería page
- Enter subject: “Newsletter - March 2026”
- Compose message with toolbar formatting:
- Bold headings for sections
- Italic for emphasis
- Links to external resources
- Review in live preview
- Click “Enviar a todos los Socios”
- Confirm in dialog
- System sends to all members with socio: ‘Socio’
- Success notification confirms delivery
Event Announcement
- Write subject: “Urgent: Assembly Meeting Tomorrow”
- Compose message:
- Preview formatting
- Send to all socios
- All active members receive professional email
Individual Follow-up
- From Usuarios page, search for specific member
- Click mail icon next to their name
- MailModal opens with recipient pre-filled
- Compose personalized message
- Send email to individual member
- Track communication in member history
Emergency Communication
- Use bulk email for urgent announcements
- Clear subject line indicating urgency
- Brief, formatted message
- Link to more information if needed
- Rapid delivery to all active members
Email Deliverability
The system uses NestJS Mailer module with configurable SMTP settings: Configuration (typically inapp.module.ts):
Email configuration requires environment variables for SMTP credentials. Ensure proper mail server setup for reliable delivery.
Integration with Other Features
-
Member Management:
- Recipient selection from Usuarios table
- Filtering by socio status for bulk emails
- Individual email buttons on member cards
-
Verification System:
- Separate verification email template (not shown in UI)
- 6-digit code delivery
- 15-minute expiration
Security Considerations
-
Role-Based Access:
- Individual emails:
adminormonitorroles - Bulk emails:
adminrole only - JWT authentication required
- Individual emails:
-
Confirmation Dialogs:
- Bulk sends require explicit confirmation
- Prevents accidental mass emails
-
No-Reply Header:
- Footer explicitly states “do not respond”
- Prevents inbox flooding from member replies
-
Email Validation:
- Filters out members without email addresses
- Returns error if no valid recipients
Related Documentation
- Member Management - Understanding member email data and socio status
- Configuration - Association email settings and SMTP configuration
