mail

Implements queued, template-driven email sending in OrangeHRM using Symfony Mailer and Twig.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill mail-snow-gift111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mail
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/mail
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill mail-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Sending emails in OrangeHRM involves a queue-and-deferred-send architecture that is easy to misuse: emails queued via EmailService are only flushed by a KernelEvents::TERMINATE subscriber, templates must follow strict directory and naming conventions, and SMTP credentials are encrypted at rest. This Skill explains the full mail pipeline so you can add event-triggered notification emails, send immediate one-off emails, and debug delivery failures without guessing. ## Core Features & Use Cases - Event-driven queued email: Dispatch a domain event from a service, catch it in a subscriber, and call EmailService::queueEmailNotifications() so MailerSubscriber sends it after the HTTP response, keeping SMTP latency invisible to users. - Twig email templates with localization: Create per-plugin Mail/templates/<locale>/<emailName>/ directories with Subject.txt.twig and Body.html.twig pairs, with automatic fallback to en_US. - Direct synchronous sending: Use EmailService::sendEmail() for flows where the user waits on the result, such as password resets and the admin Send Test Email button. - Use Case: You need to email admins when a new entity is saved. Follow the end-to-end walkthrough: define an event class, dispatch it from the service, add Twig templates, write a subscriber that queues the notification, and register it in the plugin configuration. ## Quick Start Ask the agent to add an email notification that is queued and sent to admins whenever a specific entity is saved in your OrangeHRM plugin.

Frequently Asked Questions about mail

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I send an email when an entity is saved in OrangeHRM?

Dispatch a domain event from your service after persistence, then write a subscriber extending AbstractEventSubscriber that calls EmailService::queueEmailNotifications() with the email name, recipient roles, performer role, and event. Add matching Twig templates under Mail/templates/en_US/<emailName>/ and register the subscriber in the plugin configuration.

Why didn't my queued email send in OrangeHRM?

Check ohrm_email_queue to confirm the row exists, verify the subscriber is registered via addSubscriber() in the plugin configuration, and confirm SMTP settings work with the Send Test Email button. Also check orangehrm.log for MailerSubscriber entries, since the queue only drains on KernelEvents::TERMINATE.

What is the difference between queueEmailNotifications and sendEmail in OrangeHRM?

queueEmailNotifications renders templates and inserts rows into ohrm_email_queue for deferred sending after the HTTP response, while sendEmail sends synchronously and blocks the request. Use sendEmail only when the user is explicitly waiting, such as password resets or test emails.

How do I add localized email templates in OrangeHRM?

Create a new locale directory like es_ES alongside en_US under Mail/templates, matching the same email name folder and filename pattern such as <verb>Subject.txt.twig and <verb>Body.html.twig. EmailService automatically selects the recipient's locale and falls back to en_US if a template is missing.

Do emails queued in console commands get sent automatically?

No. KernelEvents::TERMINATE does not fire for console commands, so MailerSubscriber never drains the queue. Either rely on the scheduler flow or call EmailService::sendQueuedEmails() explicitly from the command.