@cryptotaxi247 / netdata-1 / commits / aaf31295c

Add support for plain text only emails (#6485)

* Add configuration for plain text only emails * Implement sending Plain Text only emails

leo-lb committed Jul 22, 2019 at 13:04 UTC aaf31295c35f790ebb3880b3f94cd787213ab98b
2 files changed +43 -10
health/notifications/alarm-notify.sh.in
+38 -10
@@ -352,6 +352,7 @@ SYSLOG_FACILITY=
352 EMAIL_SENDER=
353 EMAIL_CHARSET=$(locale charmap 2>/dev/null)
354 EMAIL_THREADING=
355 +EMAIL_PLAINTEXT_ONLY=
356
357 # irc configs
358 IRC_NICKNAME=
@@ -2093,16 +2094,7 @@ SENT_SYSLOG=$?
2094 # -----------------------------------------------------------------------------
2095 # send the email
2096
2096 -send_email <<EOF
2097 -To: ${to_email}
2098 -Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
2099 -MIME-Version: 1.0
2100 -Content-Type: multipart/alternative; boundary="multipart-boundary"
2101 -${email_thread_headers}
2102 -
2103 -This is a MIME-encoded multipart message
2104 -
2105 ---multipart-boundary
2097 +IFS='' read -r -d '' email_plaintext_part <<EOF
2098 Content-Type: text/plain; encoding=${EMAIL_CHARSET}
2099 Content-Disposition: inline
2100 Content-Transfer-Encoding: 8bit
@@ -2124,8 +2116,27 @@ Evaluated Expression : ${calc_expression}
2116 Expression Variables : ${calc_param_values}
2117
2118 The host has ${total_warnings} WARNING and ${total_critical} CRITICAL alarm(s) raised.
2119 +EOF
2120 +
2121 +if [[ "${EMAIL_PLAINTEXT_ONLY}" == "YES" ]]; then
2122 +
2123 +send_email <<EOF
2124 +To: ${to_email}
2125 +Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
2126 +MIME-Version: 1.0
2127 +Content-Type: multipart/alternative; boundary="multipart-boundary"
2128 +${email_thread_headers}
2129 +
2130 +This is a MIME-encoded multipart message
2131
2132 --multipart-boundary
2133 +${email_plaintext_part}
2134 +--multipart-boundary--
2135 +EOF
2136 +
2137 +else
2138 +
2139 +IFS='' read -r -d '' email_html_part <<EOF
2140 Content-Type: text/html; encoding=${EMAIL_CHARSET}
2141 Content-Disposition: inline
2142 Content-Transfer-Encoding: 8bit
@@ -2231,9 +2242,26 @@ Content-Transfer-Encoding: 8bit
2242 </table>
2243 </body>
2244 </html>
2245 +EOF
2246 +
2247 +send_email <<EOF
2248 +To: ${to_email}
2249 +Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
2250 +MIME-Version: 1.0
2251 +Content-Type: multipart/alternative; boundary="multipart-boundary"
2252 +${email_thread_headers}
2253 +
2254 +This is a MIME-encoded multipart message
2255 +
2256 +--multipart-boundary
2257 +${email_plaintext_part}
2258 +--multipart-boundary
2259 +${email_html_part}
2260 --multipart-boundary--
2261 EOF
2262
2263 +fi
2264 +
2265 SENT_EMAIL=$?
2266
2267 # -----------------------------------------------------------------------------
health/notifications/health_alarm_notify.conf
+5
@@ -221,6 +221,11 @@ DEFAULT_RECIPIENT_EMAIL="root"
221 # below if you want to disable it.
222 #EMAIL_THREADING="NO"
223
224 +# By default, netdata sends HTML and Plain Text emails, some clients
225 +# do not parse HTML emails such as command line clients.
226 +# To make emails readable in these clients, you can configure netdata
227 +# to not send HTML but Plain Text only emails.
228 +#EMAIL_PLAINTEXT_ONLY="YES"
229
230 #------------------------------------------------------------------------------
231 # pushover (pushover.net) global notification options