Module: check_mk
Branch: master
Commit: 4dc07ca6e436fe3ce4b34fa2a4cf01cd98098ff1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4dc07ca6e436fe…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 4 10:04:09 2014 +0200
FIX Mails sent with mail/asciimail plugin now really set the from address
---
.werks/828 | 8 ++++++++
ChangeLog | 1 +
notifications/asciimail | 9 ++++++---
notifications/mail | 9 ++++++---
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/.werks/828 b/.werks/828
new file mode 100644
index 0000000..3d4f443
--- /dev/null
+++ b/.werks/828
@@ -0,0 +1,8 @@
+Title: Mails sent with mail/asciimail plugin now really set the from address
+Level: 1
+Component: notifications
+Version: 1.2.5i5
+Date: 1404461025
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 9228911..26f3ed1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
Notifications:
* 1042 Rule based notifications: allow matching on host groups...
+ * 0828 FIX: Mails sent with mail/asciimail plugin now really set the from address
Reporting & Availability:
* 0991 FIX: Availability: optionally show time stamps as UNIX epoch time...
diff --git a/notifications/asciimail b/notifications/asciimail
index 16a0526..80ac250 100755
--- a/notifications/asciimail
+++ b/notifications/asciimail
@@ -83,8 +83,11 @@ def build_mail(target, subject, from_address, reply_to, content_txt):
return m
-def send_mail(m, target):
- p = subprocess.Popen(["/usr/sbin/sendmail", "-i", target ], stdin
= subprocess.PIPE)
+def send_mail(m, target, from_address):
+ cmd = ["/usr/sbin/sendmail", "-i", target ]
+ if from_address:
+ cmd += ['-f', from_address]
+ p = subprocess.Popen(cmd, stdin = subprocess.PIPE)
p.communicate(m.as_string())
def construct_content(context):
@@ -232,6 +235,6 @@ def main():
from_address = context.get("PARAMETER_FROM")
reply_to = context.get("PARAMETER_REPLY_TO")
m = build_mail(mailto, subject, from_address, reply_to, content_txt)
- send_mail(m, mailto)
+ send_mail(m, mailto, from_address)
main()
diff --git a/notifications/mail b/notifications/mail
index 2509d63..8663e4b 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -302,8 +302,11 @@ def multipart_mail(target, subject, from_address, reply_to,
content_txt, content
return m
-def send_mail(m, target):
- p = subprocess.Popen(["/usr/sbin/sendmail", "-i", target ], stdin
= subprocess.PIPE)
+def send_mail(m, target, from_address):
+ cmd = ["/usr/sbin/sendmail", "-i", target ]
+ if from_address:
+ cmd += ['-f', from_address]
+ p = subprocess.Popen(cmd, stdin = subprocess.PIPE)
p.communicate(m.as_string())
return True
@@ -592,6 +595,6 @@ def main():
from_address = context.get("PARAMETER_FROM")
reply_to = context.get("PARAMETER_REPLY_TO")
m = multipart_mail(mailto, subject, from_address, reply_to, content_txt,
content_html, attachments)
- send_mail(m, mailto)
+ send_mail(m, mailto, from_address)
main()