- ssnprintf (buf, buf_len,
- "MIME-Version: 1.0\r\n"
- "Content-Type: text/plain;\r\n"
- "Content-Transfer-Encoding: 8bit\r\n"
- "Subject: %s\r\n"
- "\r\n"
- "%s - %s@%s\r\n"
- "\r\n"
- "Message: %s",
- subject,
- timestamp_str,
- severity,
- n->host,
- n->message);
-
- if (!(message = smtp_add_message (session))) {
- ERROR ("notify_email plugin: cannot set SMTP message");
- return (-1);
+ ssnprintf(buf, buf_len, "MIME-Version: 1.0\r\n"
+ "Content-Type: text/plain; charset=\"US-ASCII\"\r\n"
+ "Content-Transfer-Encoding: 8bit\r\n"
+ "Subject: %s\r\n"
+ "\r\n"
+ "%s - %s@%s\r\n"
+ "\r\n"
+ "Message: %s",
+ subject, timestamp_str, severity, n->host, n->message);
+
+ pthread_mutex_lock(&session_lock);
+
+ if (session == NULL) {
+ /* Initialization failed or we're in the process of shutting down. */
+ pthread_mutex_unlock(&session_lock);
+ return (-1);
+ }
+
+ if (!(message = smtp_add_message(session))) {
+ pthread_mutex_unlock(&session_lock);
+ ERROR("notify_email plugin: cannot set SMTP message");
+ return (-1);