Can't generate an HTML email using "Camunda Send Mail Connector" & Freemarker Template


#1

Hello community,

I am trying to send a mail with HTML content using the Mail Connector for Camunda.

After configuring the connector, I manage to send a mail with a simple text content from a Camunda Process.

Now, I am trying to send a mail using a Freemarker template with a static content as a first step.

Below the configuration I am using for the connector in process.bpmn :

<camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="to">${'myMail@myDomain.fr'}</camunda:inputParameter>
            <camunda:inputParameter name="subject">${'testCamunda: '}</camunda:inputParameter>
            <camunda:inputParameter name="html">
              <camunda:script scriptFormat="freemarker" resource="templates/body-mail.ftl" />
          <camunda:connectorId>mail-send</camunda:connectorId>
</camunda:connector> 

Below the static freeMarker template I am using (I am qualifying the template as static because I am not referencing any variable in it for now). The template is located in ressources/templates/body-mail.ftl :

<html>
<head>
  <title>Welcome!</title>
</head>
<body>
  <h1>
    Hello World !
  </h1>
 <p>  This mail has been sent from a Camunda process ! </p>
</body>
</html>

With the configuration above, the connector is sending an empty body mail ! It’s like the template engine is completely ignoring the content of the template body-mail.tfl. I don’t see any errors or warnings in Camunda logs (Tomcat logs). The template is not ignored because when I change the name of the tfl file, Camunda raises a Not Found Exception.

Did I miss something in the definition of the Freemarker template ?

I am using Camunda 7.9.0 and camunda-bpm-mail-core-1.1.0

Thank you in advance for your help, advice and suggestions :slight_smile:

Best regards,
Hanane


#2

Hi @Hel,

thank you for raising this up. Can you provide the full message including the metadata from your mail client?

If a HTML body is set then it send the mail with a multi-part body. The HTML body part is of type text/html; charset=utf-8 .
What happens if you add a text body as fallback to the HTML body?

Best regards,
Philipp