[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACNQSDYYEBFGP4244TSB4G":3,"skill-same:01M6ACNQSDYYEBFGP4244TSB4G":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":40,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":7,"updatedAt":43,"install":44,"resources":57},"01M6ACNQSDYYEBFGP4244TSB4G","manage-email-services","邮件服务管理",null,"","apache\u002Fofbiz-plugins","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACMJJ1Q4WYATY4GXZ2FAVD",178,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-email-services\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD3WKAZKP84N22M6Q0DM","办公管理与协作","SCENARIO","使用场景",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C6RQ852C9AEJFCBGG1YA7S","IT 管理员","PROFESSION","适用职业",[30],"manage email services","2026-11-10 10:12:30",false,"\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\n---\nname: manage-email-services\ndescription: Configure and implement email services in OFBiz.\n---\n\n# Skill: manage-email-services\n\n## Goal\nConfigure SMTP infrastructure and implement reliable, template-driven business notifications using OFBiz Screen Widgets, FreeMarker templates, and CommunicationEvent records.\n\n## Triggers\n**ALWAYS** read this skill when:\n- Creating new email notifications or modifying existing ones.\n- Configuring SMTP settings in `general.properties`.\n- Managing `ProductStoreEmailSetting` or `EmailTemplateSetting` entities.\n\n## Use when\n- Sending automated business notifications.\n- Designing email templates with consistent branding.\n- Attaching PDF documents (e.g., invoices) to emails.\n\n## Procedure\n\n1.  **SMTP Configuration**:\n    - Configure `framework\u002Fcommon\u002Fconfig\u002Fgeneral.properties`:\n    ```properties\n    mail.notifications.enabled=Y\n    mail.smtp.relay.host=smtp.example.com\n    mail.smtp.port=465\n    mail.smtp.auth=true\n    mail.smtp.auth.user=user@example.com\n    mail.smtp.auth.password=password\n    mail.smtp.starttls.enable=Y\n    mail.smtp.ssl.enable=true\n    ```\n    - **Note**: `mail.smtp.starttls.enable` often requires `Y` in OFBiz, while other boolean flags use `true`.\n    - Use `mail.notifications.redirectTo` in development to intercept all outgoing mail.\n\n2.  **Template Definition**:\n    - **Commerce Emails**: Prefer **`ProductStoreEmailSetting`** for order-to-cash flows.\n        - Examples: Order confirmations, Shipment notifications, Return confirmations.\n    - **System Emails**: Use **`EmailTemplateSetting`** for generic\u002Fadministrative alerts.\n        - Examples: Password reset, User invitations, Administrative alerts.\n    - **Full Compatibility**: Use `altBodyScreenLocation` to provide a plain-text fallback for HTML emails.\n    - Example XML Data:\n    ```xml\n    \u003CProductStoreEmailSetting productStoreId=\"9000\" emailType=\"PRDS_ODR_CONFIRM\" \n        bodyScreenLocation=\"component:\u002F\u002Fecommerce\u002Fwidget\u002FEmailOrderScreens.xml#OrderConfirmNotice\" \n        altBodyScreenLocation=\"component:\u002F\u002Fecommerce\u002Fwidget\u002FEmailOrderScreens.xml#OrderConfirmNoticeText\"\n        subject=\"Order Confirmation #${orderId}\" fromAddress=\"orders@example.com\"\u002F>\n    ```\n\n3.  **Store & WebSite Mapping**:\n    - `ProductStoreEmailSetting` relies on the **`WebSite`** entity (via `productStoreId`) to determine the base URL for links.\n    - Ensure your `WebSite` has `standardHostName` and `secureHostName` configured to avoid broken links in emails.\n\n4.  **Screen Design**:\n    - Create a screen in your component's `widget\u002FEmailScreens.xml`.\n    - Ensure all links and images use **absolute URLs**.\n    - **Pro-Tip**: Use `NotificationServices.setBaseUrl(delegator, webSiteId, bodyParameters)` in your logic before sending to populate `${baseUrl}` in FTL.\n\n5.  **Service Invocation**:\n    - Use `sendMailFromScreen` for granular control and PDF attachments.\n    - Use `sendMailFromTemplateSetting` for simple entity-driven sending.\n    - **ALWAYS** use `runAsync` (asynchronous) for production mailing to prevent thread blocking.\n\n6.  **Handling Attachments**:\n    - **PDF Generation**: Use `xslfoAttachScreenLocation` to render a Screen Widget as a PDF using Apache FOP.\n    - **General Files**: Use the `bodyParts` parameter (list of Maps) to attach existing files.\n\n7.  **Bulk and High-Volume Mailing**:\n    - For high-volume notifications (e.g., shipment updates), use **Job Queuing**.\n    - **Pattern**: Iterate through your targets and schedule the mailing service via `dispatcher.schedule`.\n    - **NEVER** send thousands of emails in a single service execution or a single DB transaction.\n\n## CommunicationEvent Lifecycle\n\nIn 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.\n\n### Why it Matters\n- **Customer Service Visibility**: Agents can see exactly what was sent to a customer from any module (Order, Marketing, SFA).\n- **Business Audit Trail**: Emails are linked to business documents (e.g., `OrderHeader`) via `CommunicationEventOrder`.\n- **Interaction History**: Provides a complete timeline of customer touchpoints.\n- **Compliance**: Ensures legal and support records are archived within the database, not just on a mail server.\n\n### The Lifecycle Pattern\n1.  **Creation**: A service (e.g., `sendOrderNotificationScreen`) invokes `sendMailFromScreen`.\n2.  **Persistence**: The `sendMail` service family includes SECA (Service ECA) triggers that automatically create a `CommunicationEvent` record.\n3.  **Linkage**: The `communicationEventId` is then linked to the relevant business object (e.g., `OrderHeader`, `Shipment`, or `ContactList`).\n\n## Attachments and PDF Generation\n\nOFBiz excels at generating and attaching documents like **Invoices, Packing Slips, and Return Labels** directly within the mail services.\n\n### The PDF Pattern (`xslfoAttachScreenLocation`)\nThis is the most common pattern for business documents. You provide a screen location, and the service renders it as a PDF attachment.\n\n- **Service**: `sendMailFromScreen`\n- **Parameter**: `xslfoAttachScreenLocation` (e.g., `component:\u002F\u002Faccounting\u002Fwidget\u002FInvoiceScreens.xml#InvoicePDF`)\n- **Expert Guidance**: For designing XSL-FO templates and report screens, refer to the [manage-pdf-export](..\u002Fmanage-pdf-export\u002FSKILL.md) skill.\n- **Attachment Name**: Pass `attachmentName` to set the filename (e.g., `Invoice_10000.pdf`).\n\n### Multi-part Pattern (`bodyParts`)\nFor non-PDF attachments (e.g., CSVs, images) or multiple files, use `sendMailMultiPart`.\n- **Parameter**: `bodyParts` (A `List` of `Map` objects containing `content`, `type`, and `filename`).\n\n## Guardrails\n\n- **Transactional Integrity**: **CRITICAL.** Commit business transactions *before* triggering emails. Use `runAsync` or After-Commit SECAs to prevent SMTP hangs from impacting DB locks.\n- **Fault Tolerance**: SMTP failures must **NEVER** break the main user workflow. Log errors, update `CommunicationEvent` status, but ensure primary actions succeed.\n- **Modern Security**: Externalize secrets (Env vars\u002FVaults). Avoid plain-text passwords in `general.properties`.\n- **Absolute Continuity**: Always provide plain-text fallbacks (`altBodyScreenLocation`) and pass `webSiteId` for correct absolute URL resolution.\n- **Pattern Compliance**: **ALWAYS** create and link `CommunicationEvent` records for auditability and customer history.\n- **Environment Safety**: Verify `mail.notifications.redirectTo` is set in dev\u002Ftest.\n\n## Examples\n\n### Example: Custom Email Screen\n```xml\n\u003Cscreen name=\"MyEmailBody\">\n    \u003Csection>\n        \u003Cactions>\n            \u003Cset field=\"title\" value=\"Special Notification\"\u002F>\n        \u003C\u002Factions>\n        \u003Cwidgets>\n            \u003Cplatform-specific>\n                \u003Chtml>\u003Chtml-template location=\"component:\u002F\u002Fmyplugin\u002Ftemplate\u002Femail\u002FMyEmailBody.ftl\"\u002F>\u003C\u002Fhtml>\n            \u003C\u002Fplatform-specific>\n        \u003C\u002Fwidgets>\n    \u003C\u002Fsection>\n\u003C\u002Fscreen>\n```\n\n### Example: Sending via Template (Groovy)\n```groovy\n\u002F\u002F Sending an order confirmation asynchronously\nrun service: 'sendMailFromTemplateSetting', with: [\n    emailTemplateSettingId: 'PRDS_ODR_CONFIRM',\n    sendTo: 'customer@example.com',\n    bodyParameters: [orderId: '10000', webSiteId: 'MyStore']\n]\n```\n\n### Example: Sending an Invoice PDF (Groovy)\n```groovy\n\u002F\u002F Sending an invoice as a PDF attachment asynchronously\nrun service: 'sendMailFromScreen', with: [\n    emailTemplateSettingId: 'INVOICE_NOTIFY',\n    sendTo: 'customer@example.com',\n    bodyParameters: [invoiceId: '10000'],\n    xslfoAttachScreenLocation: 'component:\u002F\u002Faccounting\u002Fwidget\u002FInvoiceScreens.xml#InvoicePDF',\n    attachmentName: 'Invoice_10000.pdf'\n]\n```\n\n### Example: Audit Trail Linking (Groovy)\n```groovy\n\u002F\u002F Step 1: Send the email as usual\nMap result = run service: 'sendMailFromScreen', with: [\n    emailTemplateSettingId: 'PRDS_ODR_CONFIRM',\n    sendTo: 'customer@example.com',\n    bodyParameters: [orderId: '10000']\n]\n\n\u002F\u002F Step 2: The service automatically creates a CommunicationEvent.\n\u002F\u002F Step 3: Link it to your business document for visibility.\nString commEventId = result.communicationEventId;\nrun service: 'createCommunicationEventOrder', with: [\n    communicationEventId: commEventId,\n    orderId: '10000'\n]\n```\n\n## Anti-Patterns\n\n### 1. Synchronous Mailing in Transactions\n**BAD**: If SMTP hangs, the order creation fails or hangs indefinitely.\n```groovy\n\u002F\u002F Inside createOrder service\nrun service: 'createOrder', with: parameters\n\u002F\u002F ANTI-PATTERN: Sending synchronously inside the transaction\nrun service: 'sendOrderConfirmation', with: parameters \n```\n**GOOD**: Decouple delivery from business logic.\n```groovy\n\u002F\u002F Inside createOrder service\nrun service: 'createOrder', with: parameters\n\u002F\u002F Success: Return to caller. SECA or Post-Commit logic handles the email.\nrun service: 'sendOrderConfirmation', as: 'async', with: parameters\n```\n\n### 2. Relative URLs in Templates\n**BAD**: Images won't load in Gmail\u002FOutlook.\n```html\n\u003Cimg src=\"\u002Fimages\u002Fcompany-logo.png\"> \u003C!-- BROKEN in email clients -->\n```\n**GOOD**: Use absolute URLs (e.g., `https:\u002F\u002Fexample.com\u002Fimages\u002Fcompany-logo.png`).\n\n### 3. Hardcoding HTML in Java\n**BAD**: Frustrating to maintain and style.\n```java\nString body = \"\u003Chtml>\u003Cbody>\u003Ch1>Hello \" + name + \"\u003C\u002Fh1>\u003C\u002Fbody>\u003C\u002Fhtml>\"; \u002F\u002F ANTI-PATTERN\n```\n**GOOD**: Use Screen Widgets and FreeMarker templates.\n",{},"trunk","6c6c27710443de03e9247605d33a2e2f5bc3d1e2","ai-agent-skills\u002Fmanage-email-services",222,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins","https:\u002F\u002Fofbiz.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-12 22:04:06",{"source":9,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add apache\u002Fofbiz-plugins --skill manage-email-services",{"tool":50,"command":51},"bunx","bunx skills add apache\u002Fofbiz-plugins --skill manage-email-services",{"tool":53,"command":54},"pnpm","pnpm dlx skills add apache\u002Fofbiz-plugins --skill manage-email-services","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-email-services\u002FSKILL.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"OWNERSHIP","OTHER","其他",27,"https:\u002F\u002Fgithub.com\u002FJetBrains\u002Fintellij-community\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fpy-code-insight-counters\u002FOWNERSHIP",[65,79,91,105,119,133],{"skillNo":66,"name":67,"nameZh":68,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":69,"categories":70,"keywords":77,"publishedAt":31},"01M6ACQSN90YKJZ92MQ52D9R8H","prepush-readiness","推送前就绪检查","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fprepush-readiness\u002FSKILL.md",[71,74],{"categoryNo":72,"categoryName":73,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",{"categoryNo":75,"categoryName":76,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[78],"prepush readiness",{"skillNo":80,"name":81,"nameZh":82,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":83,"categories":84,"keywords":89,"publishedAt":31},"01M6ACQPR1WRA751V4DXVC3AHF","manage-webapps","Web 应用管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-webapps\u002FSKILL.md",[85,86],{"categoryNo":72,"categoryName":73,"taxonomyType":27,"taxonomyTypeDesc":28},{"categoryNo":87,"categoryName":88,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BWKS60NTYJHFE9FQSXGDKS","低代码应用开发",[90],"manage webapps",{"skillNo":92,"name":93,"nameZh":94,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":95,"categories":96,"keywords":103,"publishedAt":31},"01M6ACQMCX8Z7NY2CE08NCV6ND","manage-themes","主题管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-themes\u002FSKILL.md",[97,100],{"categoryNo":98,"categoryName":99,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TQMKHSMFVQHR2KYAEVN","界面设计师",{"categoryNo":101,"categoryName":102,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[104],"manage themes",{"skillNo":106,"name":107,"nameZh":108,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":109,"categories":110,"keywords":117,"publishedAt":31},"01M6ACQHYN20AFWF6TKK4RGQ8A","manage-tests","测试管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-tests\u002FSKILL.md",[111,114],{"categoryNo":112,"categoryName":113,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":115,"categoryName":116,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[118],"manage tests",{"skillNo":120,"name":121,"nameZh":122,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":123,"categories":124,"keywords":131,"publishedAt":31},"01M6ACQFRMW7R45YD3HRAXPGWF","manage-templates","模板管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-templates\u002FSKILL.md",[125,128],{"categoryNo":126,"categoryName":127,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TK1MPB82068236GSXDE","文档处理",{"categoryNo":129,"categoryName":130,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TPH3VQWKQZXV7EPF8VZ","办公行政人员",[132],"manage templates",{"skillNo":134,"name":135,"nameZh":136,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":137,"categories":138,"keywords":143,"publishedAt":31},"01M6ACQCSSDZQMD8VX2K3WRR93","manage-strategies","策略管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-strategies\u002FSKILL.md",[139,142],{"categoryNo":140,"categoryName":141,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BTXF8K9DFQC4T4TXVH0NMZ","策略与托管设置管理",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},[144],"manage strategies"]