Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 183808 | Differences between
and this patch

Collapse All | Expand All

(-)pym/portage_mail.py (-1 / +15 lines)
Lines 74-86 Link Here
74
		try:
74
		try:
75
			if int(mymailport) > 100000:
75
			if int(mymailport) > 100000:
76
				myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
76
				myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
77
				# the additional ehlos are necessary to get some of the more esoteric servers (gmail) to talk.
78
				myconn.ehlo()
77
				myconn.starttls()
79
				myconn.starttls()
80
				myconn.ehlo()
78
			else:
81
			else:
79
				myconn = smtplib.SMTP(mymailhost, mymailport)
82
				myconn = smtplib.SMTP(mymailhost, mymailport)
80
			if mymailuser != "" and mymailpasswd != "":
83
			if mymailuser != "" and mymailpasswd != "":
81
				myconn.login(mymailuser, mymailpasswd)
84
				myconn.login(mymailuser, mymailpasswd)
82
			myconn.sendmail(myfrom, myrecipient, message.as_string())
85
			myconn.sendmail(myfrom, myrecipient, message.as_string())
83
			myconn.quit()
86
			# Gmail (and maybe others) do not properly close the connection when using tls
87
			# The mail is still sent, and the error that is raised cannot be fixed save by
88
			# the server admin. Therefore, the error should be ignored (or a warning printed)
89
			try:
90
				myconn.quit()
91
			except socket.error, e:
92
				if e[0] == 8:
93
					sys.stderr.write("!!! The mail server has not properly closed the connection:\n")
94
					sys.stderr.write("!!! "+str(e)+"\n")
95
					sys.stderr.write("!!! This error can be safely ignored.\n")
96
				else:
97
					raise e
84
		except smtplib.SMTPException, e:
98
		except smtplib.SMTPException, e:
85
			raise portage_exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e))
99
			raise portage_exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e))
86
		except socket.error, e:
100
		except socket.error, e:

Return to bug 183808