9
edits
mNo edit summary Tag: 2017 source edit |
m (Modification de la version du module et nouvelles fonctionnalités) Tag: 2017 source edit |
||
| Line 9: | Line 9: | ||
|webbuy= | |webbuy= | ||
|status=stable | |status=stable | ||
|version=1.5. | |version=1.5.27 | ||
|minversion= | |minversion= | ||
|maxversion= | |maxversion= | ||
| Line 32: | Line 32: | ||
*'''Multi-Entity Support''': Full compatibility with Dolibarr's MultiCompany module | *'''Multi-Entity Support''': Full compatibility with Dolibarr's MultiCompany module | ||
*'''User Ownership''': Events are owned by the user who sent the email for proper notifications | *'''User Ownership''': Events are owned by the user who sent the email for proper notifications | ||
*'''REST API (Dolibarr)''': Send emails externally with <code>DOLAPIKEY</code>; optional attachments (file path or base64); link to third parties and objects; automatic Agenda event (<code>POSTMARK_SENT</code>); configurable default sender (user vs company) | |||
==Français== | ==Français== | ||
| Line 45: | Line 46: | ||
*'''Support Multi-Entités'''<span> </span>: Compatibilité complète avec le module MultiCompany de Dolibarr | *'''Support Multi-Entités'''<span> </span>: Compatibilité complète avec le module MultiCompany de Dolibarr | ||
*'''Propriété utilisateur'''<span> </span>: Les événements appartiennent à l'utilisateur qui a envoyé l'email pour des notifications correctes | *'''Propriété utilisateur'''<span> </span>: Les événements appartiennent à l'utilisateur qui a envoyé l'email pour des notifications correctes | ||
*'''API REST (Dolibarr)'''<span> </span>: Envoi depuis l’extérieur avec <code>DOLAPIKEY</code>; pièces jointes (chemin serveur ou base64); liaison tiers et objet; événement agenda automatique (<code>POSTMARK_SENT</code>); expéditeur par défaut réglable : compte utilisateur ou société Dolibarr (mysoc) | |||
=Features= | =Features= | ||
| Line 57: | Line 59: | ||
* Handles attachments, CC, BCC, Reply-To headers | * Handles attachments, CC, BCC, Reply-To headers | ||
* Supports multiple message streams (transactional, marketing) | * Supports multiple message streams (transactional, marketing) | ||
* Intercepts sends via Dolibarr hooks (<code>sendMail</code> on contexts <code>mail</code>, <code>sendmail</code>, <code>all</code>) and substitution of <code>dol_mail</code> (<code>postmarkapp_sendmail</code>) so code paths using <code>dol_mail</code> can also route through Postmark when the replacement mailer option is enabled | |||
*'''REST API (native Dolibarr)''' | |||
* Endpoint <code>POST /api/index.php/postmarkappapi/send-email</code> (HTTPS) | |||
* Authentication: HTTP header <code>DOLAPIKEY</code> (user API key) | |||
* Required permission <code>postmarkapp->api</code> (admins implicitly allowed unless restricted by your Dolibarr configuration) | |||
* Body or query JSON: <code>to</code>, <code>subject</code>, <code>message</code>; optional <code>cc</code>/<code>bcc</code>, <code>fk_soc</code>, <code>fk_element</code> + <code>element_type</code>, <code>user_id</code>, <code>attachments[]</code> (<code>file_path</code> or <code>base64</code>) | |||
* <code>from_mode</code> (optional): <code>user</code> (From = API user email, fallback to company if missing) or <code>company</code> (From = Dolibarr main company « mysoc » email). If omitted, constant <code>POSTMARKAPP_DEFAULT_FROM_MODE</code> applies. No fallback to generic <code>MAIN_MAIL_DEFAULT_FROM</code> or <code>noreply</code>: HTTP 400 if no valid sender | |||
* Response fields include <code>from_mode</code> and <code>from_source</code> (<code>user</code>, <code>company</code>, <code>company_fallback</code>) | |||
* Localization of generated Agenda labels follows <code>Content-Language</code> then <code>Accept-Language</code> | |||
* Full reference: <code>API.md</code> in the module directory | |||
*'''Real-time Event Tracking''' | *'''Real-time Event Tracking''' | ||
| Line 109: | Line 123: | ||
* All interface elements translated | * All interface elements translated | ||
* Event labels and descriptions translated | * Event labels and descriptions translated | ||
*'''Administration pages''' | |||
* Main setup: '''Setup → Modules → PostmarkApp''' (<code>admin/setup.php</code>) | |||
* Tab '''About''' (<code>admin/about.php</code>): module metadata, README excerpt, contextual help on API sender rules and checking that rich-text help renders as HTML (not raw tags) | |||
* Tab '''Changelog''' (<code>admin/changelog.php</code>): rendered <code>ChangeLog.md</code> (version history) | |||
==Requirements== | ==Requirements== | ||
| Line 120: | Line 140: | ||
*'''Server API Token''': From Postmark dashboard | *'''Server API Token''': From Postmark dashboard | ||
*'''Agenda Module''': Must be enabled (mandatory dependency) | *'''Agenda Module''': Must be enabled (mandatory dependency) | ||
*'''REST API users''': Grant permission <code>postmarkapp->api</code> and assign a Dolibarr API key for each integration account | |||
==Postmark Requirements== | ==Postmark Requirements== | ||
| Line 151: | Line 172: | ||
*The Agenda module is enabled | *The Agenda module is enabled | ||
*Automatic triggers are visible in '''Setup > Modules > Agenda > Automatic events''' | *Automatic triggers are visible in '''Setup > Modules > Agenda > Automatic events''' | ||
*For REST integrations: '''Users → Permissions''' includes <code>postmarkapp->api</code> where needed and API keys assigned | |||
===Step 1: Server API Token=== | ===Step 1: Server API Token=== | ||
| Line 194: | Line 214: | ||
* When disabled, Dolibarr uses its native email system | * When disabled, Dolibarr uses its native email system | ||
* Recommended: Keep enabled for consistent tracking | * Recommended: Keep enabled for consistent tracking | ||
*'''API default sender (From)''' | |||
* Constant <code>POSTMARKAPP_DEFAULT_FROM_MODE</code>: <code>user</code> (default From = authenticated API user email) or <code>company</code> (default From = main company « mysoc » email from '''Home → Setup → Company/Organization'''). | |||
* For <code>company</code> mode en production: the company email must be a verified Sender Signature in Postmark. | |||
* Constant <code>POSTMARKAPP_SOCIETE_FROM_CONFIRMED</code> + checkbox « Postmark confirmation » on the setup page: the administrator must explicitly confirm that the company From is authorized on Postmark. | |||
* Saving in <code>company</code> mode is '''refused''' if the mysoc email is missing or syntactically invalid. | |||
* Test email action uses the configured mode so verification matches production behaviour. | |||
* Per-request API override remains possible via <code>from_mode</code> (see '''REST API''' above). | |||
===Step 3: Webhook Configuration (Optional but Recommended)=== | ===Step 3: Webhook Configuration (Optional but Recommended)=== | ||
| Line 287: | Line 316: | ||
postmarkapp/ | postmarkapp/ | ||
├── core/ | ├── core/ | ||
│ | │ ├── modules/ | ||
│ | │ │ └── modPostmarkApp.class.php # Module descriptor, menus, hooks, constants | ||
│ └── substitutions/ | |||
│ └── postmarkapp.lib.php # dol_mail → postmarkapp_sendmail | |||
├── class/ | ├── class/ | ||
│ | │ ├── actions_postmarkapp.class.php # Hook handlers (sendMail, mail_begin/end) | ||
│ └── api_postmarkapp.class.php # Dolibarr REST API (send-email) | |||
├── lib/ | ├── lib/ | ||
│ ├── postmarkapp.lib.php # Admin tabs, sender helpers (mysoc validation) | |||
│ └── class/ | │ └── class/ | ||
│ | │ ├── postmarkappmail.class.php # Postmark API wrapper | ||
│ └── lysistech.class.php # Optional remote last-version URL helper | |||
├── admin/ | ├── admin/ | ||
│ | │ ├── setup.php # Configuration | ||
│ ├── about.php # About + embedded help | |||
│ └── changelog.php # Rendered ChangeLog.md | |||
├── events.php # Events list page | ├── events.php # Events list page | ||
├── webhook.php # Webhook endpoint | ├── webhook.php # Webhook endpoint | ||
├── API.md # Detailed REST documentation | |||
├── ChangeLog.md | |||
└── langs/ | └── langs/ | ||
└── [lang]/ | └── [lang]/ | ||
└── postmarkapp.lang | └── postmarkapp.lang # Translations | ||
</pre> | </pre> | ||
| Line 307: | Line 345: | ||
The module uses Dolibarr's hook system to intercept email sending: | The module uses Dolibarr's hook system to intercept email sending: | ||
*'''Hook | *'''Hook contexts''' (registered in the module descriptor): <code>mail</code>, <code>sendmail</code>, <code>all</code> | ||
*'''Primary hook''': <code>sendMail</code> | |||
*'''Hook File''': <code>class/actions_postmarkapp.class.php</code> | *'''Hook File''': <code>class/actions_postmarkapp.class.php</code> | ||
*'''Hook Method''': <code>sendMail($parameters, &$object, &$action, $hookmanager)</code> | *'''Hook Method''': <code>sendMail($parameters, &$object, &$action, $hookmanager)</code> | ||
*'''Additional handlers''': <code>mail_begin</code>, <code>mail_end</code> where applicable for the same contexts | |||
'''How It Works:''' | '''How It Works:''' | ||
| Line 319: | Line 359: | ||
#Logs the "Sent" event to database | #Logs the "Sent" event to database | ||
#Returns 1 to prevent native Dolibarr email sending | #Returns 1 to prevent native Dolibarr email sending | ||
===dol_mail substitution=== | |||
When substitution files are loaded, calls to Dolibarr <code>dol_mail()</code> can be diverted to Postmark via <code>postmarkapp_sendmail()</code> in <code>core/substitutions/postmarkapp.lib.php</code> (same prerequisites: module enabled, valid Server Token, Replace Mailer as required). Behaviour matches other intercepted sends (metadata trackid/objects when supplied in extra parameters). | |||
===API Integration=== | ===API Integration=== | ||
| Line 447: | Line 491: | ||
===Permissions=== | ===Permissions=== | ||
The module defines | The module defines '''three''' permissions: | ||
*'''postmarkapp_read''': View email events (required for events list page) | *'''postmarkapp_read''': View email events (required for events list page; menu '''Tools → PostmarkApp events''' / <code>events.php</code>) | ||
*'''postmarkapp_setup''': Configure the module (required for setup page) | *'''postmarkapp_setup''': Configure the module (required for setup page) | ||
*'''postmarkapp_api''': Call the Dolibarr REST endpoint <code>postmarkappapi/send-email</code> | |||
Permissions are checked using: | Permissions are checked using: | ||
<code>if ($user->hasRight('postmarkapp', 'read'))</code> | <code>if ($user->hasRight('postmarkapp', 'read'))</code> | ||
<code>if ($user->hasRight('postmarkapp', 'setup'))</code> | <code>if ($user->hasRight('postmarkapp', 'setup'))</code> | ||
<code>if ($user->hasRight('postmarkapp', 'api'))</code> | |||
===Remote version check (optional)=== | |||
The module descriptor can expose <code>LysisTech::getLastModuleVersionUrl()</code> so Dolibarr may query a remote « last version » string. Restricted outbound HTTPS environments may log failures unrelated to runtime sending. Define <code>DOLIBARR_LYSIS_SKIP_VERSION_CHECK</code> in <code>conf/conf.php</code> to silence that check when needed (same pattern as other Lysis-published modules). | |||
===Menu=== | |||
*Events list appears under '''Tools''' (not a dedicated top-level main menu). | |||
===Important module constants=== | |||
In addition to token and webhook settings, noteworthy keys include: | |||
*<code>POSTMARKAPP_DEFAULT_FROM_MODE</code>: <code>user</code> or <code>company</code> — default REST API sender mode | |||
*<code>POSTMARKAPP_SOCIETE_FROM_CONFIRMED</code>: admin confirmation flag for Postmark-aligned company sender | |||
*<code>MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML</code>: enforced by activation when HTML/click-tracking behaviour is desired (already documented above) | |||
===Webhook Processing=== | ===Webhook Processing=== | ||
| Line 583: | Line 645: | ||
*Verify "Track Clicks" option is enabled in configuration | *Verify "Track Clicks" option is enabled in configuration | ||
*Check that links in emails are not already rewritten by another system | *Check that links in emails are not already rewritten by another system | ||
===REST API errors (send-email)=== | |||
#'''401 / 403''': Confirm header <code>DOLAPIKEY</code>, user login bound to that key has <code>postmarkapp->api</code>, module PostmarkApp enabled | |||
#'''400 (sender)''': No valid From — set the API user email, or configure a valid '''Company''' email matching a Postmark Sender Signature; in <code>company</code> mode check setup validation and confirmation checkbox | |||
#Consult <code>dolibarr.log</code> and full examples in '''API.md''' | |||
===Events Not Appearing in Agenda=== | ===Events Not Appearing in Agenda=== | ||
| Line 605: | Line 673: | ||
=Changelog= | =Changelog= | ||
===Current release (module descriptor: 1.5.27)=== | |||
See also <code>ChangeLog.md</code> inside the package and the '''Changelog''' tab in administration. | |||
===Version 1.5.25=== | |||
*Documentation reminders: REST API sender configuration (<code>user</code> / <code>company</code>, confirmation), About page help (API response fields <code>from_mode</code> / <code>from_source</code>, HTTP 400 if no sender, HTML rendering of help) | |||
===Version 1.5.24=== | |||
*Module icons: addition of correct <code>img/</code> files so Dolibarr <code>img_object</code> URLs no longer return 404 | |||
===Version 1.5.23=== | |||
*'''Changelog''' tab in administration; '''About''' page aligned with Dolibarr module info layout | |||
===Version 1.5.22=== | |||
*'''About''' page displays <code>ChangeLog.md</code> correctly again alongside README | |||
===Version 1.5.10=== | |||
*'''Default REST sender''' constants <code>POSTMARKAPP_DEFAULT_FROM_MODE</code> and <code>POSTMARKAPP_SOCIETE_FROM_CONFIRMED</code> | |||
*'''Setup''' UI: sender mode selection, displayed mysoc email, link to company card, mandatory Postmark confirmation in company mode, save blocked if enterprise email invalid, test mail aligned with mode | |||
*'''REST''' <code>send-email</code>: optional <code>from_mode</code>, <code>user_id</code>, response metadata <code>from_mode</code> / <code>from_source</code>, structured errors instead of anonymous <code>noreply</code> fallback | |||
*Helpers <code>postmarkapp_get_mysoc_sender()</code>, <code>postmarkapp_is_valid_sender_email()</code> | |||
===Version 1.5.2 (2026-01-06)=== | ===Version 1.5.2 (2026-01-06)=== | ||
| Line 649: | Line 744: | ||
*Installation and configuration of the PostmarkApp module | *Installation and configuration of the PostmarkApp module | ||
*REST API integrations (<code>DOLAPIKEY</code>, <code>from_mode</code>, attachments) | |||
*Postmark account setup and sender signature verification | *Postmark account setup and sender signature verification | ||
*Webhook configuration and testing | *Webhook configuration and testing | ||
| Line 663: | Line 759: | ||
*L'installation et la configuration du module PostmarkApp | *L'installation et la configuration du module PostmarkApp | ||
*Les intégrations API REST (<code>DOLAPIKEY</code>, <code>from_mode</code>, pièces jointes) | |||
*La création de votre compte Postmark et la vérification des signatures d'expéditeur | *La création de votre compte Postmark et la vérification des signatures d'expéditeur | ||
*La configuration et les tests des webhooks | *La configuration et les tests des webhooks | ||
edits