Mailfrom hooks: processing documents via e-mail

Process documents via e-mail with mailfrom hooks: unique token address, transformation and custom domain.

Not every system can deliver documents through an API connection. With a mailfrom hook you make it possible to submit documents as e-mail attachments to the PSB. The PSB generates a unique e-mail address with a token (for example [email protected]). Any document sent as an attachment to this address is automatically processed as an invoice, order or other document type.

How does a mailfrom hook work?

When you create a mailfrom hook the PSB generates a unique token address. You configure via a publishTopic what should happen with the incoming documents, for example sending via Peppol (SendInvoice) or processing as a received document (ReceiveInvoice).

The flow is as follows:

  1. You register a mailfrom hook with a publishTopic
  2. The PSB generates a unique e-mail address with a token
  3. A user or system sends an e-mail with document attachment(s) to this address
  4. The PSB processes the attachments as documents and publishes them on the specified topic
  5. Any follow-up actions (sending, transformation) are executed automatically
Creating a mailfrom hook

Register a hook via the API with a mailfrom:// action. Use $token$ as a placeholder; the PSB replaces this with the generated token in the response.

{
  "id": "1",
  "name": "mail from trigger",
  "action": "mailfrom://*&[email protected]",
  "publishTopics": [
    "SendInvoice"
  ],
  "isActive": true
}

After registration the response contains the actual token address:

mailfrom://*&[email protected]

From that moment on, all attachments sent to [email protected] are processed as invoices and published on the SendInvoice topic.

Action format

The action is composed of a from and to part:

mailfrom://{from}&to={to}

The token address can be placed in either the from or the to part. At least one of the two must contain the token, so the PSB can link the e-mail to the correct hook.

Variants
ConfigurationDescriptionmailfrom://*&[email protected]Accept e-mails from any sender address, token in the recipient addressmailfrom://[email protected]&[email protected]Token in the sender address, fixed recipient address. Useful with a custom domain

The wildcard * in the from part means that e-mails from any sender address are accepted. If you want to restrict which senders may submit documents, enter a specific e-mail address.

Environments
EnvironmentE-mail domainAcceptance@accp.econnect.emailProduction@econnect.email

Note: always use the correct domain per environment. E-mails sent to the production domain are processed as real documents and cannot be undone.

Document transformation

Optionally you can specify a sourceDocumentTypeId and targetDocumentTypeId as query parameters. The PSB then automatically transforms the attachment to the specified target format, provided a suitable transformation is available. Special characters in the documentTypeId must be URL-encoded.

{
  "id": "1",
  "name": "mail from met transformatie",
  "action": "mailfrom://*&[email protected]?sourceDocumentTypeId=urn%3Aoasis%3Anames%3Aspecification%3Aubl%3Aschema%3Axsd%3AInvoice-2%3A%3AInvoice%23%23urn%3Acen.eu%3Aen16931%3A2017%23compliant%23urn%3Afdc%3Anen.nl%3Anlcius%3Av1.0%3A%3A2.1&targetDocumentTypeId=urn%3Aoasis%3Anames%3Aspecification%3Aubl%3Aschema%3Axsd%3AInvoice-2%3A%3AInvoice%23%23urn%3Acen.eu%3Aen16931%3A2017%23compliant%23urn%3Afdc%3Anen.nl%3Anlcius%3Av1.0%3A%3A2.1",
  "publishTopics": [
    "SendInvoice"
  ],
  "isActive": true
}
Publish topics

A mailfrom hook supports exactly one publishTopic. This topic determines how the PSB processes the incoming documents.

Publish topicUse caseSendInvoiceSend the invoice via the configured channel (e.g. Peppol)ReceiveInvoiceRegister the document as a received invoiceRecognizeSalesInvoiceSubmit the document to IDR for PDF recognition

Tip: by using RecognizeSalesInvoice as the publish topic, you can submit PDF invoices by e-mail and have them automatically recognised by the IDR. This combines mailfrom with intelligent document recognition.

Custom domain

By default the PSB uses the domain econnect.email (or accp.econnect.email for acceptance). It is also possible to use a custom domain, so the e-mail address matches your own organisation. Contact eConnect to set this up.

Points of attention
  • Mailfrom hooks only process attachments. The body text of the e-mail itself is not processed as a document.
  • Each hook supports a maximum of one publishTopic. For different processing types (sending, receiving, recognition) you create separate hooks.
  • Make sure the attachments are in a supported format (XML, PDF). Other file types are not processed.
Frequently asked questions
Why do I use the placeholder $token$ in the mailfrom action?

During registration the PSB replaces $token$ with the generated unique token in the e-mail address; the response contains the definitive mailfrom:// path. Only addresses with that token are linked to your hook, so incoming mail is processed specifically.

Which e-mail domain belongs to acceptance versus production?

For acceptance you use addresses on @accp.econnect.email, for production on @econnect.email. E-mails to the production domain are processed as real document flows and cannot easily be reversed; choose the environment deliberately.

Can I combine multiple processing types (send, receive, recognise) in one mailfrom hook?

No: a mailfrom hook supports exactly one publishTopic. For different processing types, such as SendInvoice, ReceiveInvoice or RecognizeSalesInvoice, you create separate hooks, each with its own token address and publish topic.


See the full API specification at psb.econnect.eu for all configuration options and examples.

View the API documentation