Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions 22 Lib/smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#
# This was modified from the Python 1.5 library HTTP lib.

from __future__ import print_function

import socket
import io
import re
Expand Down Expand Up @@ -335,12 +337,14 @@ def connect(self, host='localhost', port=0, source_address=None):
raise OSError("nonnumeric port")
if not port:
port = self.default_port
sys.audit("smtplib.connect", self, host, port)
#sys.audit("smtplib.connect", self, host, port)
self.sock = self._get_socket(host, port, self.timeout)
self.file = None
(code, msg) = self.getreply()
if self.debuglevel > 0:
self._print_debug('connect:', repr(msg))
if code == 220:
self._host = host
return (code, msg)

def send(self, s):
Expand All @@ -353,7 +357,7 @@ def send(self, s):
# should not be used, but 'data' needs to convert the string to
# binary itself anyway, so that's not a problem.
s = s.encode(self.command_encoding)
sys.audit("smtplib.send", self, s)
#sys.audit("smtplib.send", self, s)
try:
self.sock.sendall(s)
except OSError:
Expand Down Expand Up @@ -416,7 +420,7 @@ def getreply(self):

errmsg = b"\n".join(resp)
if self.debuglevel > 0:
self._print_debug('reply: retcode (%s); Msg: %a' % (errcode, errmsg))
self._print_debug('reply: retcode (%s); Msg: %s' % (errcode, errmsg))
return errcode, errmsg

def docmd(self, cmd, args=""):
Expand Down Expand Up @@ -606,7 +610,7 @@ def ehlo_or_helo_if_needed(self):
if not (200 <= code <= 299):
raise SMTPHeloError(code, resp)

def auth(self, mechanism, authobject, *, initial_response_ok=True):
def auth(self, mechanism, authobject, initial_response_ok=True):
"""Authentication command - requires response processing.

'mechanism' specifies which authentication mechanism is to
Expand Down Expand Up @@ -667,7 +671,7 @@ def auth_login(self, challenge=None):
else:
return self.password

def login(self, user, password, *, initial_response_ok=True):
def login(self, user, password, initial_response_ok=True):
"""Log in on an SMTP server that requires authentication.

The arguments are:
Expand Down Expand Up @@ -950,7 +954,7 @@ def send_message(self, msg, from_addr=None, to_addrs=None,
del msg_copy['Resent-Bcc']
international = False
try:
''.join([from_addr, *to_addrs]).encode('ascii')
''.join([from_addr, ] + to_addrs).encode('ascii')
except UnicodeEncodeError:
if not self.has_extn('smtputf8'):
raise SMTPNotSupportedError(
Expand All @@ -962,7 +966,7 @@ def send_message(self, msg, from_addr=None, to_addrs=None,
if international:
g = email.generator.BytesGenerator(
bytesmsg, policy=msg.policy.clone(utf8=True))
mail_options = (*mail_options, 'SMTPUTF8', 'BODY=8BITMIME')
mail_options = mail_options + ('SMTPUTF8', 'BODY=8BITMIME')
else:
g = email.generator.BytesGenerator(bytesmsg)
g.flatten(msg_copy, linesep='\r\n')
Expand Down Expand Up @@ -1037,9 +1041,9 @@ def __init__(self, host='', port=0, local_hostname=None,
def _get_socket(self, host, port, timeout):
if self.debuglevel > 0:
self._print_debug('connect:', (host, port))
new_socket = super()._get_socket(host, port, timeout)
new_socket = SMTP._get_socket(self, host, port, timeout)
new_socket = self.context.wrap_socket(new_socket,
server_hostname=self._host)
server_hostname=host)
return new_socket

__all__.append("SMTP_SSL")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.