How to include line breaks when sending messages

This document describes how to include line breaks when sending messages in PhenixID Server.

The reader of this document should have some basic knowledge about PhenixID Server.

System requirements

  • PhenixID Server installed.

Overview

When using the SMTPValve or SMSValve to deliver messages, there might be a need to include line breaks to make the message easier to read.

This document will describe how to add those line breaks to the message.

We will make changes to the configuration file phenix-store.json, so please make sure to have a backup  of this file.

Instruction

Before we get to the SMTPValve or SMSValve we will add a PropertyAddValve.
We will then use the property created with the valve used for sending.
In the example below we have used property expansion to collect information, earlier in the flow, so we will use that to make up the email message.
New lines will be added by using "\n".

Example configuration for the PropertyAddValve, with line breaks in the message:

{
"name": "PropertyAddValve",
"config": {
"name": "body",
"value": "A new user has been created in the system.\n\nName: {{item.givenName}} {{item.sn}}\nCompany: {{item.businessCategory}}\nE-mail address: {{item.mail}}\nMobile: {{item.mobile}}"
}
}

Message will now be sent with a a blank line after:
A new user has been created in the system.
And then separate lines for:
Name
Company
E-mail address
Mobile


We can now use this in the valve used to send the message, by setting the value {{item.body}}.
Example for SMTPValve :

{
"name": "SMTPValve",
"config": {
"mail_template": "",
"smtp_username": "mailadmin",
"smtp_password": "",
"smtp_host": "192.168.12.28",
"smtp_port": "25",
"mail_param_name": "{{item.info}}",
"userid_param_name": "{{item.givenName}}",
"smtp_from_address": "System  < [email protected] >",
"start_tls_enabled": "true",
"message_subject": "New user created in the system",
"message_body": "{{item.body}}"
}
}

Example for SMSValve:

{
"name": "SMSValve",
"enabled": "true",
"config": {
"proceed_on_error": "false",
"recipient_param_name": "{{item.nummer}}",
"message_key": "valves.delivery.sms.message",
"message": "{{item.body}}",
"userid_param_name": "User-Name",
"wash_recipient_number": "true",
"force_prefix": "false",
"remove_leading_plus": "false"
},