Module PostmarkApp: Difference between revisions

Jump to navigation Jump to search
m
Modification de la version du module et nouvelles fonctionnalités
mNo edit summary
Tag: 2017 source edit
m (Modification de la version du module et nouvelles fonctionnalités)
Tag: 2017 source edit
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Complementary modules]]
[[Category:PostmarkApp]]
{{TemplateDocDevEn}}
{{TemplateDocUser}}
=Informations=
{{TemplateModuleInfo
{{TemplateModuleInfo
|name=PostmarkApp
|modulename=PostmarkApp
|editor=Alex BORDARAUD - Lysis
|editor=Alex BORDARAUD - Lysis https://lysis.net
|contact=alex@lysis.net
|webbuy=
|web=https://lysis.net
|status=stable
|dolistore=
|version=1.5.27
|minversion=1.5.2
|minversion=
|maxversion=
|note=
}}
}}


Line 11: Line 18:
'''PostmarkApp''' is a professional Dolibarr module that integrates [https://postmarkapp.com Postmark], a transactional email service, to replace Dolibarr's native email sending system. It provides complete email traceability, real-time event tracking, and seamless integration with Dolibarr's Agenda module.
'''PostmarkApp''' is a professional Dolibarr module that integrates [https://postmarkapp.com Postmark], a transactional email service, to replace Dolibarr's native email sending system. It provides complete email traceability, real-time event tracking, and seamless integration with Dolibarr's Agenda module.


==Description==
=Description=


===English===
==English==


PostmarkApp transforms your email communications in Dolibarr by providing enterprise-grade email delivery and tracking. Unlike standard SMTP, Postmark ensures high deliverability rates and provides detailed analytics on every email sent.
PostmarkApp transforms your email communications in Dolibarr by providing enterprise-grade email delivery and tracking. Unlike standard SMTP, Postmark ensures high deliverability rates and provides detailed analytics on every email sent.
Line 25: 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==


PostmarkApp transforme vos communications email dans Dolibarr en fournissant une livraison et un suivi d'emails de niveau entreprise. Contrairement au SMTP standard, Postmark garantit des taux de délivrabilité élevés et fournit des analyses détaillées sur chaque email envoyé.
PostmarkApp transforme vos communications email dans Dolibarr en fournissant une livraison et un suivi d'emails de niveau entreprise. Contrairement au SMTP standard, Postmark garantit des taux de délivrabilité élevés et fournit des analyses détaillées sur chaque email envoyé.
Line 38: 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=


===Core Features===
==Core Features==


*'''Email Sending via Postmark API'''
*'''Email Sending via Postmark API'''
Line 50: 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 102: 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 113: 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==


*Verified Sender Signatures for the "From" email addresses
*Verified Sender Signatures for the "From" email addresses
Line 120: Line 148:
*Webhook URL accessible from internet (for event tracking)
*Webhook URL accessible from internet (for event tracking)


==Installation==
=Installation=


===Step-by-Step Installation===
==Step-by-Step Installation==


#Download the module package <code>module_postmarkapp-x.y.z.zip</code>
#Download the module package <code>module_postmarkapp-x.y.z.zip</code>
Line 137: Line 165:
#Configure the module in '''Setup > Modules > PostmarkApp > Settings'''
#Configure the module in '''Setup > Modules > PostmarkApp > Settings'''


===Post-Installation===
==Post-Installation==


After installation, verify:
After installation, verify:
Line 144: 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
==Configuration==


===Step 1: Server API Token===
===Step 1: Server API Token===
Line 187: 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 244: Line 280:
#Use the webhook test buttons to verify event processing
#Use the webhook test buttons to verify event processing


==MultiCompany Compatibility==
=MultiCompany Compatibility=


PostmarkApp is fully compatible with Dolibarr's MultiCompany module.
PostmarkApp is fully compatible with Dolibarr's MultiCompany module.


===How It Works===
==How It Works==


*Each email event is stored with an <code>entity</code> field
*Each email event is stored with an <code>entity</code> field
Line 254: Line 290:
*Events can be shared between entities if MultiCompany sharing is enabled
*Events can be shared between entities if MultiCompany sharing is enabled


===Configuration===
==Configuration==


#Enable the MultiCompany module in Dolibarr
#Enable the MultiCompany module in Dolibarr
Line 261: Line 297:
#Enable/disable sharing as needed
#Enable/disable sharing as needed


===Sharing Behavior===
==Sharing Behavior==


*'''Sharing Disabled''': Each entity only sees its own email events
*'''Sharing Disabled''': Each entity only sees its own email events
Line 267: Line 303:
*The webhook automatically uses the entity from the original "Sent" event
*The webhook automatically uses the entity from the original "Sent" event


===Entity Assignment===
==Entity Assignment==


*When an email is sent, the event is assigned to the current entity (<code>$conf->entity</code>)
*When an email is sent, the event is assigned to the current entity (<code>$conf->entity</code>)
Line 273: Line 309:
*This ensures proper data isolation and sharing
*This ensures proper data isolation and sharing


==Technical Architecture==
=Technical Architecture=


===Module Structure===
==Module Structure==


<pre>
<pre>
postmarkapp/
postmarkapp/
├── core/
├── core/
│  └── modules/
│  ├── modules/
│       └── modPostmarkApp.class.php    # Module descriptor
│   │  └── modPostmarkApp.class.php    # Module descriptor, menus, hooks, constants
│  └── substitutions/
│      └── postmarkapp.lib.php        # dol_mail → postmarkapp_sendmail
├── class/
├── class/
│  └── actions_postmarkapp.class.php  # Hook handlers
│  ├── 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
│      ├── postmarkappmail.class.php  # Postmark API wrapper
│      └── lysistech.class.php        # Optional remote last-version URL helper
├── admin/
├── admin/
│  └── setup.php                      # Configuration page
│  ├── 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           # Translations
         └── postmarkapp.lang             # Translations
</pre>
</pre>


Line 300: 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 Name''': <code>sendMail</code>
*'''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 312: 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 440: Line 491:
===Permissions===
===Permissions===


The module defines two permissions:
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 576: 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 597: Line 672:
<!-- Add screenshots here when available -->
<!-- Add screenshots here when available -->


==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 626: Line 728:
*Object linking
*Object linking


==Links==
=Links=


*[https://postmarkapp.com Postmark Official Website]
*[https://postmarkapp.com Postmark Official Website]
*[https://lysis.net Lysis - Developer Website]
*[https://lysis.net Lysis - Developer Website]


==License==
=License=


This module is distributed under the [https://www.gnu.org/licenses/gpl-3.0 GNU General Public License v3 (GPLv3)].
This module is distributed under the [https://www.gnu.org/licenses/gpl-3.0 GNU General Public License v3 (GPLv3)].


==Professional Services / Services professionnels==
=Professional Services / Services professionnels=


===English===
===English===
Line 642: 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 656: 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
Line 665: Line 769:
Contactez-nous pour un devis personnalisé<span> </span>: https://lysis.net
Contactez-nous pour un devis personnalisé<span> </span>: https://lysis.net


==Author==
=Author=


'''Alex BORDARAUD'''<br />
'''Alex BORDARAUD'''<br />
Website: https://lysis.net
Website: https://lysis.net
[[Category:External module]]
[[Category:Communication module]]
[[Category:Email module]]
[[Category:MultiCompany compatible]]

Navigation menu