--- pym/portage_mail.py 2007-07-01 19:01:16.000000000 -0400 +++ pym/portage_mail.py 2007-07-01 19:23:31.000000000 -0400 @@ -74,13 +74,27 @@ try: if int(mymailport) > 100000: myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000) + # the additional ehlos are necessary to get some of the more esoteric servers (gmail) to talk. + myconn.ehlo() myconn.starttls() + myconn.ehlo() else: myconn = smtplib.SMTP(mymailhost, mymailport) if mymailuser != "" and mymailpasswd != "": myconn.login(mymailuser, mymailpasswd) myconn.sendmail(myfrom, myrecipient, message.as_string()) - myconn.quit() + # Gmail (and maybe others) do not properly close the connection when using tls + # The mail is still sent, and the error that is raised cannot be fixed save by + # the server admin. Therefore, the error should be ignored (or a warning printed) + try: + myconn.quit() + except socket.error, e: + if e[0] == 8: + sys.stderr.write("!!! The mail server has not properly closed the connection:\n") + sys.stderr.write("!!! "+str(e)+"\n") + sys.stderr.write("!!! This error can be safely ignored.\n") + else: + raise e except smtplib.SMTPException, e: raise portage_exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e)) except socket.error, e: