Send Notification to more than one address

Hello @all!

I try to optimize my workflow to get missing certificates. The old way: The user tries to send an e-mail to a domain with the policy “mandatory”. If this is impossible because a certificate is missing, the system notifies him, that this process failed. Now the user has to notify me about this error and i have to get the certificate and add it to the cyphermail-gateway. So far, so good.

What i try: The notification about the failed encryption has to be send to the original user AND to my ticketsystem. In the template i have informed the user, that this notificachion was send to the administrator. If possible, i would send it to my ticketsystem as “Bcc:”, but if not, its ok.

I tried to customize my template for notification about failed encryption and putted the address to all possible fields, but no luck.

From: <${from!"postmaster"}>
<#if to??>
To: <#list to as recipient><${recipient}><#if recipient?has_next>, </#if>, ciphermail@mydomain.de</#list>
</#if>
<#if replyTo??>
Reply-To: <${replyTo}>
</#if>
Subject: Die E-Mail konnte...
From: <${from!"postmaster"}>
<#if to??>
To: <#list to as recipient><${recipient}><#if recipient?has_next>, </#if></#list>
</#if>
Cc: ciphermail@mydomain.de
<#if replyTo??>
Reply-To: <${replyTo}>
</#if>
Subject: Die E-Mail konnte...

The communication to all mailservers (inbound, outbound) is ok. When i try to send a testmail from MTA → actions → send e-mail, all mails arrive the recipients (multiple recipients in th “To:”-field too).

In users outlook i can see both recipients in the mailinformations, so the fields are correct filled. It seems, ciphermail sends the notification just as answer to the original sender and ignores the fields in the template.

Can i archive my goal with ciphermail or has i to inform my users, that they has to send me theyr error-notifications?

Greets

Steffen

You can only set the message headers (like To and Cc) from a template, not change the (envelope) recipients.

The easiest imho, is to use Postfix headers checks with a BCC action.

Add a special header to the encrypion failed template

Open the Failed Encryption Notification template and add the following header:

X-CipherMail-Certificate-Not-Available: True

Add after queue header checks

This can be done with the CLI or with the UI.

With the UI

  1. click MTA → MAPS
  2. From Actios, select Add Map
  3. Set name to after-queue-header-checks
  4. Set type to PCRE
  5. Set content to /^X-CipherMail-Certificate-Not-Available:.*/ BCC ticket@example.com
  6. Click Save

Note: change ticket@example.com with the correct email address

Configure Postfix to check headers for emails received from back-end

This step should be done from the command line.

Note: this step assumes that you use the community edition With the pro version, Postfix master config file is managed by ansible. Contact us if you are using the pro version.

sudo vi /etc/postfix/master.cf 

Set header_checks to the full path of the newly created header checks file:

# cleanup for the after queue filter
port_10026_cleanup unix  n       -       n       -       0       cleanup
            -o hopcount_limit=100
            -o header_checks=pcre:/etc/postfix/maps.d/pcre-after-queue-header-checks.map
            -o mime_header_checks=
            -o nested_header_checks=
            -o body_checks=
            -o milter_header_checks=
            -o smtp_header_checks=
            -o smtp_mime_header_checks=
            -o smtp_nested_header_checks=
            -o smtp_body_checks=

Restart Postfix

sudo systemctl restart postfix.service

Now when an email cannot be encrypted, the notification email will contain the special X-CipherMail-Certificate-Not-Available header. The header check will then add a BCC to the email.