@@ -43,63 +43,59 @@ def _unifiedheaderinit(self, *args, **kw
setattr(email.header.Header, '__init__', _unifiedheaderinit)
class STARTTLS(smtplib.SMTP):
'''Derived class to verify the peer certificate for STARTTLS.
This class allows to pass any keyword arguments to SSL socket creation.
'''
- def __init__(self, ui, sslkwargs, host=None, **kwargs):
+ def __init__(self, ui, host=None, **kwargs):
smtplib.SMTP.__init__(self, **kwargs)
self._ui = ui
- self._sslkwargs = sslkwargs
self._host = host
def starttls(self, keyfile=None, certfile=None):
if not self.has_extn("starttls"):
msg = "STARTTLS extension not supported by server"
raise smtplib.SMTPException(msg)
(resp, reply) = self.docmd("STARTTLS")
if resp == 220:
self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile,
ui=self._ui,
- serverhostname=self._host,
- **self._sslkwargs)
+ serverhostname=self._host)
self.file = smtplib.SSLFakeFile(self.sock)
self.helo_resp = None
self.ehlo_resp = None
self.esmtp_features = {}
self.does_esmtp = 0
return (resp, reply)
class SMTPS(smtplib.SMTP):
'''Derived class to verify the peer certificate for SMTPS.
This class allows to pass any keyword arguments to SSL socket creation.
'''
- def __init__(self, ui, sslkwargs, keyfile=None, certfile=None, host=None,
+ def __init__(self, ui, keyfile=None, certfile=None, host=None,
**kwargs):
self.keyfile = keyfile
self.certfile = certfile
smtplib.SMTP.__init__(self, **kwargs)
self._host = host
self.default_port = smtplib.SMTP_SSL_PORT
self._ui = ui
- self._sslkwargs = sslkwargs
def _get_socket(self, host, port, timeout):
if self.debuglevel > 0:
print('connect:', (host, port), file=sys.stderr)
new_socket = socket.create_connection((host, port), timeout)
new_socket = sslutil.wrapsocket(new_socket,
self.keyfile, self.certfile,
ui=self._ui,
- serverhostname=self._host,
- **self._sslkwargs)
+ serverhostname=self._host)
self.file = smtplib.SSLFakeFile(new_socket)
return new_socket
def _smtp(ui):
'''build an smtp connection and return a function to send mail'''
local_hostname = ui.config('smtp', 'local_hostname')
tls = ui.config('smtp', 'tls', 'none')
# backward compatible: when tls = true, we use starttls.
@@ -111,25 +107,22 @@ def _smtp(ui):
if not mailhost:
raise error.Abort(_('smtp.host not configured - cannot send mail'))
verifycert = ui.config('smtp', 'verifycert', 'strict')
if verifycert not in ['strict', 'loose']:
if util.parsebool(verifycert) is not False:
raise error.Abort(_('invalid smtp.verifycert configuration: %s')
% (verifycert))
verifycert = False
- if (starttls or smtps) and verifycert:
- sslkwargs = sslutil.sslkwargs(ui, mailhost)
if smtps:
ui.note(_('(using smtps)\n'))
- s = SMTPS(ui, sslkwargs, local_hostname=local_hostname, host=mailhost)
+ s = SMTPS(ui, local_hostname=local_hostname, host=mailhost)
elif starttls:
- s = STARTTLS(ui, sslkwargs, local_hostname=local_hostname,
- host=mailhost)
+ s = STARTTLS(ui, local_hostname=local_hostname, host=mailhost)
else:
s = smtplib.SMTP(local_hostname=local_hostname)
if smtps:
defaultport = 465
else:
defaultport = 25
mailport = util.getport(ui.config('smtp', 'port', defaultport))
ui.note(_('sending mail: smtp host %s, port %d\n') %