[yocto] [yocto-autobuilder][PATCH] SendQAEmail.py: use sendmail instead of mail to send QA email

Bill Randle william.c.randle at intel.com
Tue Aug 9 09:42:10 PDT 2016


When sending QA emails, the autobuilder uses the 'mail' command (typically
installed as /usr/bin/mail or /bin/mail). However, most distributions do not
install this program by default. They generally always install the 'sendmail'
program, though, so use 'sendmail' as the mail agent, rather than 'mail'.

[YOCTO #10082]

Signed-off-by: Bill Randle <william.c.randle at intel.com>
---
 .../autobuilder/buildsteps/SendQAEmail.py          | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py b/lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py
index 0cd76d5..3691cc6 100644
--- a/lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py
+++ b/lib/python2.7/site-packages/autobuilder/buildsteps/SendQAEmail.py
@@ -47,9 +47,9 @@ class SendQAEmail(ShellCommand):
             properties = self.build.getProperties().asDict()
             repoprops = {}
             mailsubject = "Build available for QA"
-            email_header = '''
-    A build identified as needing QA has finished on the autobuilder. This
-    build is located at:\n\n
+            email_base = '''
+A build identified as needing QA has finished on the autobuilder. This
+build is located at:\n\n
     %s''' % (self.getProperty('DEST').replace(web_root, web_url))
 
             if str(self.getProperty("custom_release_me")) == "True":
@@ -68,9 +68,9 @@ class SendQAEmail(ShellCommand):
                 poky_number = self.getProperty("custom_poky_number")+prefix
                 yocto_number = self.getProperty("custom_yocto_number")+prefix
                 rel_name = 'yocto-'+ yocto_number
-                email_header = '''
+                email_base = '''
 A release candidate build for %s is now available at:\n\n
-%s\n\n
+    %s\n\n
 Please begin QA on this build as soon as possible.''' % (rel_name, self.getProperty('DEST').replace(web_root, web_url))
                 mailsubject = "Release Candidate Build for " + rel_name + snapshot + " now available."
 
@@ -85,16 +85,18 @@ Please begin QA on this build as soon as possible.''' % (rel_name, self.getPrope
             for k, v in repoprops.iteritems():
                 email_body = email_body + '%s : %s \n' % (k, v[1])
 
-            mailcmd = 'echo -e "' + email_header + '\n' + email_body + '\n' + mailsig + ' " | mail -s \'' + mailsubject + '\''
-
+            email_header = ""
+            if mailto is not None and mailto is not "":
+                email_header += "To: " + mailto + "\n"
             if mailcc is not None and mailcc is not "":
-                mailcmd += " -c '" + mailcc + "' "
-
+                email_header += "Cc: " + mailcc + "\n"
             if mailbcc is not None and mailbcc is not "":
-                mailcmd += " -b '" + mailbcc + "' "
+                email_header += "Bcc: " + mailbcc + "\n"
+
+            email_header += "Subject: " + mailsubject + "\n"
+
+            mailcmd = 'echo -e "' + email_header + "\n" + email_base + '\n' + email_body + '\n' + mailsig + ' " | sendmail -t'
 
-            if mailto is not None and mailto is not "":
-                mailcmd += " '" + mailto + "' "
             self.command = mailcmd
         else:
             self.command = 'echo "Not a QA build"'
-- 
2.5.5




More information about the yocto mailing list