Alert email includes all text in attachment with new line is used is message

Hello Icinga community,
I have a strange problem when a newline / carriage return are included in the alert email message. This causes the whole text of the message to get included in an attachment to the email instead of contained in the body of the email.

I am using the default ‘mail-host-notification.sh’ script. I have made a few changes but nothing too major. I have included the debug log below for reference. You can see in line 3 the ‘\r\n’ in sent from Icingaweb as an API command. You can see in line 17 that the ‘\r\n’ is removed when the command is sent by command line. When the ‘\r\n’ (return key) are included in the message of the email all the text from the email are attached to the email instead of included in the body of the email.

Has anyone experienced this problem or have solution?

[2022-01-11 16:24:40 -0500] information/ApiListener: New client connection from [127.0.0.1]:37840 (no client certificate)
[2022-01-11 16:24:40 -0500] notice/ApiListener: New HTTP client
[2022-01-11 16:24:40 -0500] debug/HttpUtility: Request body: '{"author":"admin","comment":"this has two line in the message\r\nline two of the message","force":false,"host":"USDCXVDAS117"}'
[2022-01-11 16:24:40 -0500] notice/ApiActionHandler: Running action send-custom-notification
[2022-01-11 16:24:40 -0500] information/Checkable: Checkable 'USDCXVDAS117' has 1 notification(s). Checking filters for type 'Custom', sends will be logged.
[2022-01-11 16:24:40 -0500] notice/Notification: Attempting to send notifications of type 'Custom' for notification object 'USDCXVDAS117!mail-host-notification'.
[2022-01-11 16:24:40 -0500] debug/Notification: Type 'Custom', TypeFilter: Acknowledgement, Custom, DowntimeEnd, DowntimeRemoved, DowntimeStart, FlappingEnd, FlappingStart, Problem and Recovery (FType=8, TypeFilter=511)
[2022-01-11 16:24:40 -0500] debug/Notification: User 'icinga' notification 'USDCXVDAS117!mail-host-notification', Type 'Custom', TypeFilter: Acknowledgement, Custom, DowntimeEnd, DowntimeRemoved, DowntimeStart, FlappingEnd, FlappingStart, Problem and Recovery (FType=8, TypeFilter=511)
[2022-01-11 16:24:40 -0500] debug/Notification: User 'icinga' notification 'USDCXVDAS117!mail-host-notification', State 'Up', StateFilter: Critical, Down, OK, Unknown, Up and Warning (FState=16, StateFilter=63)
[2022-01-11 16:24:40 -0500] information/Notification: Sending 'Custom' notification 'USDCXVDAS117!mail-host-notification' for user 'icinga'
[2022-01-11 16:24:40 -0500] debug/Notification: User 'admin_email' notification 'USDCXVDAS117!mail-host-notification', Type 'Custom', TypeFilter: Acknowledgement, Custom, DowntimeEnd, DowntimeRemoved, DowntimeStart, FlappingEnd, FlappingStart, Problem and Recovery (FType=8, TypeFilter=511)
[2022-01-11 16:24:40 -0500] debug/Notification: User 'admin_email' notification 'USDCXVDAS117!mail-host-notification', State 'Up', StateFilter: Critical, Down, OK, Unknown, Up and Warning (FState=16, StateFilter=63)
[2022-01-11 16:24:40 -0500] information/Notification: Sending 'Custom' notification 'USDCXVDAS117!mail-host-notification' for user 'admin_email'
[2022-01-11 16:24:40 -0500] information/HttpServerConnection: Request: POST /v1/actions/send-custom-notification (from [127.0.0.1]:37840), user: icingaweb2, agent: , status: OK).
[2022-01-11 16:24:40 -0500] notice/ApiListener: Relaying 'event::SendNotifications' message
[2022-01-11 16:24:40 -0500] notice/ApiListener: Relaying 'event::SetForceNextNotification' message
[2022-01-11 16:24:40 -0500] notice/ApiListener: Relaying 'event::NotificationSentToAllUsers' message
[2022-01-11 16:24:40 -0500] notice/Process: Running command '/etc/icinga2/scripts/mail-host-notification.sh' '-4' '10.156.94.109' '-6' '' '-b' 'admin' '-c' 'this has two line in the message
line two of the message' '-d' '2022-01-11 16:24:40 -0500' '-f' 'Sun Chemical Monitoring<icinga2@sunchemical.com>' '-i' 'https://monitoring.sunchemical.com/icingaweb2' '-l' 'USDCXVDAS117' '-n' 'USDCXVDAS117' '-o' 'PING OK - Packet loss = 0%, RTA = 0.08 ms' '-r' 'Nagios_Administrators@sunchemical.com' '-s' 'UP' '-t' 'CUSTOM' '-v' 'false' '-z' '1': PID 1490
[2022-01-11 16:24:40 -0500] information/Notification: Completed sending 'Custom' notification 'USDCXVDAS117!mail-host-notification' for checkable 'USDCXVDAS117' and user 'icinga' using command 'mail-host-notification'.
[2022-01-11 16:24:40 -0500] notice/ApiListener: Relaying 'event::NotificationSentUser' message
[2022-01-11 16:24:40 -0500] notice/Process: Running command '/etc/icinga2/scripts/mail-host-notification.sh' '-4' '10.156.94.109' '-6' '' '-b' 'admin' '-c' 'this has two line in the message
line two of the message' '-d' '2022-01-11 16:24:40 -0500' '-f' 'Sun Chemical Monitoring<icinga2@sunchemical.com>' '-i' 'https://monitoring.sunchemical.com/icingaweb2' '-l' 'USDCXVDAS117' '-n' 'USDCXVDAS117' '-o' 'PING OK - Packet loss = 0%, RTA = 0.08 ms' '-r' 'alexclark1105@gmail.com' '-s' 'UP' '-t' 'CUSTOM' '-v' 'false' '-z' '1': PID 1491
[2022-01-11 16:24:40 -0500] information/Notification: Completed sending 'Custom' notification 'USDCXVDAS117!mail-host-notification' for checkable 'USDCXVDAS117' and user 'admin_email' using command 'mail-host-notification'.
[2022-01-11 16:24:40 -0500] notice/ApiListener: Relaying 'event::NotificationSentUser' message
[2022-01-11 16:24:40 -0500] information/HttpServerConnection: HTTP client disconnected (from [127.0.0.1]:37840)

Icinga 2 version

 icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: 2.11.11-1)

Copyright (c) 2012-2022 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Red Hat Enterprise Linux Server
  Platform version: 7.7 (Maipo)
  Kernel: Linux
  Kernel version: 3.10.0-1160.49.1.el7.x86_64
  Architecture: x86_64

Build information:
  Compiler: GNU 4.8.5
  Build host: runner-hh8q3bz2-project-507-concurrent-0

Application information:

General paths:
  Config directory: /etc/icinga2
  Data directory: /var/lib/icinga2
  Log directory: /var/log/icinga2
  Cache directory: /var/cache/icinga2
  Spool directory: /var/spool/icinga2
  Run directory: /run/icinga2

Old paths (deprecated):
  Installation root: /usr
  Sysconf directory: /etc
  Run directory (base): /run
  Local state directory: /var

Internal paths:
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid

Icingaweb2 version

 icingacli --version
Icinga Web 2  2.7.6
Git Commit    13d357373e025c5550d4320a5f8ac45ad75ff0d7
PHP Version   7.1.30
MODULE       VERSION
doc          2.7.6
globe        1.0.4
graphite     1.1.0
idoreports   0.9.1
incubator    0.5.0
ipl          v0.4.0
map          1.0.4
monitoring   2.7.6
nagvis       1.1.1
pdfexport    0.9.0
reactbundle  0.7.0
reporting    0.9.2
setup        2.7.6
translation  2.7.6
vspheredb    1.1.0

Thanks in advance for your help
Alex