0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 22:52:30 +00:00

Add support for plain text only emails ()

* Add configuration for plain text only emails

* Implement sending Plain Text only emails
This commit is contained in:
leo-lb 2019-07-22 13:04:20 +02:00 committed by Chris Akritidis
parent 4a1c750a0c
commit aaf31295c3
2 changed files with 43 additions and 10 deletions

View file

@ -352,6 +352,7 @@ SYSLOG_FACILITY=
EMAIL_SENDER= EMAIL_SENDER=
EMAIL_CHARSET=$(locale charmap 2>/dev/null) EMAIL_CHARSET=$(locale charmap 2>/dev/null)
EMAIL_THREADING= EMAIL_THREADING=
EMAIL_PLAINTEXT_ONLY=
# irc configs # irc configs
IRC_NICKNAME= IRC_NICKNAME=
@ -2093,16 +2094,7 @@ SENT_SYSLOG=$?
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# send the email # send the email
send_email <<EOF IFS='' read -r -d '' email_plaintext_part <<EOF
To: ${to_email}
Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="multipart-boundary"
${email_thread_headers}
This is a MIME-encoded multipart message
--multipart-boundary
Content-Type: text/plain; encoding=${EMAIL_CHARSET} Content-Type: text/plain; encoding=${EMAIL_CHARSET}
Content-Disposition: inline Content-Disposition: inline
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
@ -2124,8 +2116,27 @@ Evaluated Expression : ${calc_expression}
Expression Variables : ${calc_param_values} Expression Variables : ${calc_param_values}
The host has ${total_warnings} WARNING and ${total_critical} CRITICAL alarm(s) raised. The host has ${total_warnings} WARNING and ${total_critical} CRITICAL alarm(s) raised.
EOF
if [[ "${EMAIL_PLAINTEXT_ONLY}" == "YES" ]]; then
send_email <<EOF
To: ${to_email}
Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="multipart-boundary"
${email_thread_headers}
This is a MIME-encoded multipart message
--multipart-boundary --multipart-boundary
${email_plaintext_part}
--multipart-boundary--
EOF
else
IFS='' read -r -d '' email_html_part <<EOF
Content-Type: text/html; encoding=${EMAIL_CHARSET} Content-Type: text/html; encoding=${EMAIL_CHARSET}
Content-Disposition: inline Content-Disposition: inline
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
@ -2231,9 +2242,26 @@ Content-Transfer-Encoding: 8bit
</table> </table>
</body> </body>
</html> </html>
EOF
send_email <<EOF
To: ${to_email}
Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="multipart-boundary"
${email_thread_headers}
This is a MIME-encoded multipart message
--multipart-boundary
${email_plaintext_part}
--multipart-boundary
${email_html_part}
--multipart-boundary-- --multipart-boundary--
EOF EOF
fi
SENT_EMAIL=$? SENT_EMAIL=$?
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View file

@ -221,6 +221,11 @@ DEFAULT_RECIPIENT_EMAIL="root"
# below if you want to disable it. # below if you want to disable it.
#EMAIL_THREADING="NO" #EMAIL_THREADING="NO"
# By default, netdata sends HTML and Plain Text emails, some clients
# do not parse HTML emails such as command line clients.
# To make emails readable in these clients, you can configure netdata
# to not send HTML but Plain Text only emails.
#EMAIL_PLAINTEXT_ONLY="YES"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# pushover (pushover.net) global notification options # pushover (pushover.net) global notification options