apache/ofbiz-plugins/manage-email-services
Claude Code and agent skill by apache/ofbiz-plugins
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Configure and implement email services in OFBiz.
Install
npx vskill@latest install apache/ofbiz-plugins/manage-email-servicesSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as apache/ofbiz-plugins/manage-email-services.
Skill: manage-email-services
Goal
Configure SMTP infrastructure and implement reliable, template-driven business notifications using OFBiz Screen Widgets, FreeMarker templates, and CommunicationEvent records.
Triggers
ALWAYS read this skill when:
- Creating new email notifications or modifying existing ones.
- Configuring SMTP settings in
general.properties. - Managing
ProductStoreEmailSettingorEmailTemplateSettingentities.
Use when
- Sending automated business notifications.
- Designing email templates with consistent branding.
- Attaching PDF documents (e.g., invoices) to emails.
Procedure
- SMTP Configuration:
- Configure
framework/common/config/general.properties:
``properties mail.notifications.enabled=Y mail.smtp.relay.host=smtp.example.com mail.smtp.port=465 mail.smtp.auth=true mail.smtp.auth.user=user@example.com mail.smtp.auth.password=password mail.smtp.starttls.enable=Y mail.smtp.ssl.enable=true ``
- Note:
mail.smtp.starttls.enableoften requiresYin OFBiz, while other boolean flags usetrue. - Use
mail.notifications.redirectToin development to intercept all outgoing mail.
- Template Definition:
- Commerce Emails: Prefer `ProductStoreEmailSetting` for order-to-cash flows.
- Examples: Order confirmations, Shipment notifications, Return confirmations.
- System Emails: Use `EmailTemplateSetting` for generic/administrative alerts.
- Examples: Password reset, User invitations, Administrative alerts.
- Full Compatibility: Use
altBodyScreenLocationto provide a plain-text fallback for HTML emails. - Example XML Data:
``xml <ProductStoreEmailSetting productStoreId="9000" emailType="PRDS_ODR_CONFIRM" bodyScreenLocation="component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNotice" altBodyScreenLocation="component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNoticeText" subject="Order Confirmation #${orderId}" fromAddress="orders@example.com"/> ``
- Store & WebSite Mapping:
ProductStoreEmailSettingrelies on the `WebSite` entity (viaproductStoreId) to determine the base URL for links.- Ensure your
WebSitehasstandardHostNameandsecureHostNameconfigured to avoid broken links in emails.
- Screen Design:
- Create a screen in your component's
widget/EmailScreens.xml. - Ensure all links and images use absolute URLs.
- Pro-Tip: Use
NotificationServices.setBaseUrl(delegator, webSiteId, bodyParameters)in your logic before sending to populate${baseUrl}in FTL.
- Service Invocation:
- Use
sendMailFromScreenfor granular control and PDF attachments. - Use
sendMailFromTemplateSettingfor simple entity-driven sending. - ALWAYS use
runAsync(asynchronous) for production mailing to prevent thread blocking.
- Handling Attachments:
- PDF Generation: Use
xslfoAttachScreenLocationto render a Screen Widget as a PDF using Apache FOP. - General Files: Use the
bodyPartsparameter (list of Maps) to attach existing files.
- Bulk and High-Volume Mailing:
- For high-volume notifications (e.g., shipment updates), use Job Queuing.
- Pattern: Iterate through your targets and schedule the mailing service via
dispatcher.schedule. - NEVER send thousands of emails in a single service execution or a single DB transaction.
CommunicationEvent Lifecycle
In OFBiz, emails are not just "logged"—they are managed as Communication Events. This is a core architectural pattern that ensures every outbound email has a central source of truth.
Why it Matters
- Customer Service Visibility: Agents can see exactly what was sent to a customer from any module (Order, Marketing, SFA).
- Business Audit Trail: Emails are linked to business documents (e.g.,
OrderHeader) viaCommunicationEventOrder. - Interaction History: Provides a complete timeline of customer touchpoints.
- Compliance: Ensures legal and support records are archived within the database, not just on a mail server.
The Lifecycle Pattern
- Creation: A service (e.g.,
sendOrderNotificationScreen) invokessendMailFromScreen. - Persistence: The
sendMailservice family includes SECA (Service ECA) triggers that automatically create aCommunicationEventrecord. - Linkage: The
communicationEventIdis then linked to the relevant business object (e.g.,OrderHeader,Shipment, orContactList).
Attachments and PDF Generation
OFBiz excels at generating and attaching documents like Invoices, Packing Slips, and Return Labels directly within the mail services.
The PDF Pattern (xslfoAttachScreenLocation)
This is the most common pattern for business documents. You provide a screen location, and the service renders it as a PDF attachment.
- Service:
sendMailFromScreen - Parameter:
xslfoAttachScreenLocation(e.g.,component://accounting/widget/InvoiceScreens.xml#InvoicePDF) - Expert Guidance: For designing XSL-FO templates and report screens, refer to the manage-pdf-export skill.
- Attachment Name: Pass
attachmentNameto set the filename (e.g.,Invoice_10000.pdf).
Multi-part Pattern (bodyParts)
For non-PDF attachments (e.g., CSVs, images) or multiple files, use sendMailMultiPart.
- Parameter:
bodyParts(AListofMapobjects containingcontent,type, andfilename).
Guardrails
- Transactional Integrity: CRITICAL. Commit business transactions before triggering emails. Use
runAsyncor After-Commit SECAs to prevent SMTP hangs from impacting DB locks. - Fault Tolerance: SMTP failures must NEVER break the main user workflow. Log errors, update
CommunicationEventstatus, but ensure primary actions succeed. - Modern Security: Externalize secrets (Env vars/Vaults). Avoid plain-text passwords in
general.properties. - Absolute Continuity: Always provide plain-text fallbacks (
altBodyScreenLocation) and passwebSiteIdfor correct absolute URL resolution. - Pattern Compliance: ALWAYS create and link
CommunicationEventrecords for auditability and customer history. - Environment Safety: Verify
mail.notifications.redirectTois set in dev/test.
Examples
Example: Custom Email Screen
Example: Sending via Template (Groovy)
Example: Sending an Invoice PDF (Groovy)
Example: Audit Trail Linking (Groovy)
Anti-Patterns
1. Synchronous Mailing in Transactions
BAD: If SMTP hangs, the order creation fails or hangs indefinitely.
GOOD: Decouple delivery from business logic.
2. Relative URLs in Templates
BAD: Images won't load in Gmail/Outlook.
GOOD: Use absolute URLs (e.g., https://example.com/images/company-logo.png).
3. Hardcoding HTML in Java
BAD: Frustrating to maintain and style.
GOOD: Use Screen Widgets and FreeMarker templates.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingai-agent-skills/manage-email-services/SKILL.md
Popularity
- Repository stars
- 176
- Repository forks
- 222
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/apache/ofbiz-plugins/manage-email-services)