Handle Exceptions in mod_mail_summary.finalize() and
authorZac Medico <zmedico@gentoo.org>
Fri, 12 Oct 2007 05:51:13 +0000 (05:51 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 12 Oct 2007 05:51:13 +0000 (05:51 -0000)
check if the server actually supports TLS, bug #183808
(trunk r7984 and r8058)

svn path=/main/branches/2.1.2/; revision=8059

pym/elog_modules/mod_mail_summary.py
pym/portage_mail.py

index d42f6453e5ebcb225708b6f672e70364c8e4c77a..c89613131b0308e59951e177520d6b6d21d6f5f0 100644 (file)
@@ -4,6 +4,8 @@
 # $Id: mod_mail.py 3484 2006-06-10 22:38:44Z genone $
 
 import portage_mail, socket, os, time
+from portage_exception import PortageException
+from portage_util import writemsg
 from email.MIMEText import MIMEText as TextMessage
 
 _items = {}
@@ -48,6 +50,9 @@ def _finalize(mysettings, items):
 
        mymessage = portage_mail.create_message(myfrom, myrecipient, mysubject,
                mybody, attachments=items.values())
-       portage_mail.send_mail(mysettings, mymessage)
+       try:
+               portage_mail.send_mail(mysettings, mymessage)
+       except PortageException, e:
+               writemsg("%s\n" % str(e), noiselevel=-1)
 
        return
index 99ed77fda1640cbe9a629ba6d758cea36d864e17..d12f85c07b685e0fbf649a45922a1ceb8f04822b 100644 (file)
@@ -74,7 +74,11 @@ def send_mail(mysettings, message):
                try:
                        if int(mymailport) > 100000:
                                myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
+                               myconn.ehlo()
+                               if not myconn.has_extn("STARTTLS"):
+                                       raise portage_exception.PortageException("!!! TLS support requested for logmail but not suported by server")
                                myconn.starttls()
+                               myconn.ehlo()
                        else:
                                myconn = smtplib.SMTP(mymailhost, mymailport)
                        if mymailuser != "" and mymailpasswd != "":