Kaydet (Commit) 036b51db authored tarafından Justin Luth's avatar Justin Luth

tdf#63388: use SMTP_SSL for port 465

Thanks to Jurassic Pork and prrychr (tdf#99363) for the 2016 patch.
I used smtp.gmail.com as my testing server.

Port 587 is the "official" port to use for encrypted email.
I confirmed that 587 CANNOT use SMTP_SSL [SSL: UNKNOWN_PROTOCOL],
so I limited SMTP_SSL use to common TLS port 465 only.

Port 465 was temporarily recommended, but OFFICIALLY has long
since been abandoned. However, LOTS of documentation and ISPs still
recommend it as the port to use. I confirmed that 465 DOES NOT
support STARTTLS, so it is specifically excluded.

So, technically the button should say use STARTTLS instead of SSL,
but only for SMTP. IMAP/POP do use SSL, so terminology gets
rather confusing. This patch forces SSL without STARTTLS for port 465
regardless of the "use SSL" setting due to all the confusion.

Currently we don't support ANY SSL/TLS connections. With this patch
we now at least support the extremely common use case of port 465.

Change-Id: I210cc307491157c1121cfffd70cbb94347ee2856
Reviewed-on: https://gerrit.libreoffice.org/48210Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst 3deac969
......@@ -104,7 +104,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
tout = _GLOBAL_DEFAULT_TIMEOUT
if dbg:
print("Timeout: " + str(tout), file=dbgout)
self.server = smtplib.SMTP(server, port,timeout=tout)
if port == 465:
self.server = smtplib.SMTP_SSL(server, port,timeout=tout)
else:
self.server = smtplib.SMTP(server, port,timeout=tout)
#stderr not available for us under windows, but
#set_debuglevel outputs there, and so throw
......@@ -116,7 +119,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
connectiontype = xConnectionContext.getValueByName("ConnectionType")
if dbg:
print("ConnectionType: " + connectiontype, file=dbgout)
if connectiontype.upper() == 'SSL':
if connectiontype.upper() == 'SSL' and port != 465:
self.server.ehlo()
self.server.starttls()
self.server.ehlo()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment