Administration -- Extraction templates

Extraction templates (admin/inputtemplate_list.php) allow Capmail to automatically recognize emails coming from web forms (Contact Form 7, Wix, Typeform, custom...) and extract structured data from them (name, email, phone, message, etc.) to pre-fill the third party card.

Principle

When an email arrives, Capmail tests the active templates in decreasing priority order. The first whose detection rules match is used to extract the data. If no template matches, the module uses a generic parser (phones and SIREN by regex).

Template list

admin/inputtemplate_list.php displays all configured templates. Columns:

  • Reference -- identifier TPL0001.
  • Label -- business name (e.g. "Contact Form 7 -- corporate site").
  • Priority -- test order (higher = tested first).
  • Status -- active/inactive.

Template card (admin/inputtemplate_card.php)

The card is organized in 5 tabs.

"General" tab

Field Description
Label Template name (required).
Description Free description, for internal documentation.
Priority Integer. Templates with a high priority are tested before the others. Allows managing conflicts when several templates can match.
Active If unticked, the template is ignored at collection.
Automatic third party linking If enabled, the third party is linked automatically when an email matches, without confirmation.
Linking field Third party field used for matching (email, phone, etc.).

"Detection" tab

Defines when the template applies. List of rules evaluated in AND logic: all must match for the template to apply.

Each rule has:

  • Source field -- subject, from (sender), body_text (text body), headers.
  • Operator -- contains (contained string) or regex (regular expression).
  • Value -- string or regex to compare.

Example: for Contact Form 7, a rule subject contains "Contact request".

"Extraction" tab

Defines what to extract. List of regex rules applied to the email. Each rule fills a target field.

Parameter Description
Field name Capmail field to fill: email, phone, firstname, lastname, name, company, address, zip, town, country_code, siren, siret, tva_intra, message, project_title, website.
Regex Regular expression with a capture group (the content of () becomes the extracted value).
Source Where to search: subject, from, body_text, body_html.
Flags Regex modifiers: i (case insensitive), s (dot matches \n), m (multiline).

Example: Email\s*:\s*([\w.-]+@[\w.-]+) on body_text to extract the address from a text "Email: contact@example.com".

When the source is body_html, extracted values are automatically cleaned (HTML tags removed, entities decoded).

"Default labels" tab

Dolibarr categories applied automatically to objects created from an email matching this template.

  • Third party labels -- applied to the new third party (categories of type customer).
  • Contact labels -- applied to the contact (categories of type contact).
  • Project labels -- applied to the auto-created project (categories of type project).

Allows quickly classifying leads by origin ("Website", "Trade show X 2026", etc.).

"Test" tab

Input field where you paste a sample email. The "Test" button runs the detection rules then the extraction and displays the result. Essential to validate a regex before activating the template in production.

Tips

  • Start simple: a detection rule on the subject is often enough.
  • Test each template with at least 3 real emails before activating it.
  • One template = one lead source (one form, one partner). Avoid overly generic templates that match too broadly.
  • If several templates can match (e.g. several forms on the same site), use priority to rank them.