Module: check_mk
Branch: master
Commit: 54476f301f84c6fbfa0c5f515164d917943ac474
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=54476f301f84c6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jan 16 15:41:01 2017 +0100
mail notify plugin: Slightly improved error handling
Change-Id: Ia9d4e42984e23fdcd7b2e2e9f87ebf0ae77ce8e2
---
notifications/mail | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/notifications/mail b/notifications/mail
index e4dd11f..a47de6d 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -436,12 +436,15 @@ def send_mail_sendmail(m, target, from_address):
cmd += ['-F', from_address, "-f", from_address]
cmd += [ "-i", target.encode("utf-8")]
try:
- p = subprocess.Popen(cmd, stdin = subprocess.PIPE)
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
except OSError:
raise Exception("Failed to send the mail: /usr/sbin/sendmail is
missing")
+
p.communicate(m.as_string())
+ if p.returncode != 0:
+ raise Exception("sendmail returned with exit code: %d" % p.returncode)
- sys.stdout.write("Spooled mail to local mail transmission agent")
+ sys.stdout.write("Spooled mail to local mail transmission agent\n")
return 0
def send_mail_smtp(message, target, from_address, context):