From: Zac Medico Date: Fri, 12 Oct 2007 05:51:13 +0000 (-0000) Subject: Handle Exceptions in mod_mail_summary.finalize() and X-Git-Tag: v2.1.3.16~56 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=25710c946ee439e3eee94c3417648c873e66399a;p=portage.git Handle Exceptions in mod_mail_summary.finalize() and check if the server actually supports TLS, bug #183808 (trunk r7984 and r8058) svn path=/main/branches/2.1.2/; revision=8059 --- diff --git a/pym/elog_modules/mod_mail_summary.py b/pym/elog_modules/mod_mail_summary.py index d42f6453e..c89613131 100644 --- a/pym/elog_modules/mod_mail_summary.py +++ b/pym/elog_modules/mod_mail_summary.py @@ -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 diff --git a/pym/portage_mail.py b/pym/portage_mail.py index 99ed77fda..d12f85c07 100644 --- a/pym/portage_mail.py +++ b/pym/portage_mail.py @@ -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 != "":