Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1190a38d
Commit
1190a38d
authored
Mar 09, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #957003: Implement smtplib.LMTP.
parent
fd61107e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletion
+65
-1
Doc/lib/libsmtplib.tex
Doc/lib/libsmtplib.tex
+17
-0
Lib/smtplib.py
Lib/smtplib.py
+46
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libsmtplib.tex
View file @
1190a38d
...
...
@@ -41,6 +41,23 @@ are also optional, and can contain a PEM formatted private key and
certificate chain file for the SSL connection.
\end{classdesc}
\begin{classdesc}
{
LMTP
}{
\optional
{
host
\optional
{
, port
\optional
{
,
local
_
hostname
}}}}
The LMTP protocol, which is very similar to ESMTP, is heavily based
on the standard SMTP client. It's common to use Unix sockets for LMTP,
so our connect() method must support that as well as a regular
host:port server. To specify a Unix socket, you must use an absolute
path for
\var
{
host
}
, starting with a '/'.
Authentication is supported, using the regular SMTP mechanism. When
using a Unix socket, LMTP generally don't support or require any
authentication, but your mileage might vary.
\versionadded
{
2.6
}
\end{classdesc}
A nice selection of exceptions is defined as well:
\begin{excdesc}
{
SMTPException
}
...
...
Lib/smtplib.py
View file @
1190a38d
...
...
@@ -226,6 +226,7 @@ class SMTP:
debuglevel = 0
file = None
helo_resp = None
ehlo_msg = "ehlo"
ehlo_resp = None
does_esmtp = 0
...
...
@@ -401,7 +402,7 @@ class SMTP:
host.
"""
self
.
esmtp_features
=
{}
self
.
putcmd
(
"ehlo"
,
name
or
self
.
local_hostname
)
self
.
putcmd
(
self
.
ehlo_msg
,
name
or
self
.
local_hostname
)
(
code
,
msg
)
=
self
.
getreply
()
# According to RFC1869 some (badly written)
# MTA's will disconnect on an ehlo. Toss an exception if
...
...
@@ -746,6 +747,50 @@ class SMTP_SSL(SMTP):
self.sock = SSLFakeSocket(self.sock, sslobj)
self.file = SSLFakeFile(sslobj)
#
# LMTP extension
#
LMTP_PORT = 2003
class LMTP(SMTP):
"""
LMTP
-
Local
Mail
Transfer
Protocol
The
LMTP
protocol
,
which
is
very
similar
to
ESMTP
,
is
heavily
based
on
the
standard
SMTP
client
.
It
's common to use Unix sockets for LMTP,
so our connect() method must support that as well as a regular
host:port server. To specify a Unix socket, you must use an absolute
path as the host, starting with a '
/
'.
Authentication is supported, using the regular SMTP mechanism. When
using a Unix socket, LMTP generally don'
t
support
or
require
any
authentication
,
but
your
mileage
might
vary
.
"""
ehlo_msg = "lhlo"
def __init__(self, host = '', port = LMTP_PORT, local_hostname = None):
"""
Initialize
a
new
instance
.
"""
SMTP.__init__(self, host, port, local_hostname)
def connect(self, host='localhost', port = 0):
"""
Connect
to
the
LMTP
daemon
,
on
either
a
Unix
or
a
TCP
socket
.
"""
if host[0] == '/':
try:
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(host)
except socket.error, msg:
if self.debuglevel > 0: print 'connect fail:', host
if self.sock:
self.sock.close()
self.sock = None
if not self.sock:
raise socket.error, msg
(code, msg) = self.getreply()
if self.debuglevel > 0: print "connect:", msg
return (code, msg)
else:
return SMTP.connect(self, host, port)
# Test the sendmail method, which tests most of the others.
# Note: This always sends to localhost.
if __name__ == '__main__':
...
...
Misc/NEWS
View file @
1190a38d
...
...
@@ -152,6 +152,8 @@ Core and builtins
Library
-------
- Patch #957003: Implement smtplib.LMTP.
- Patch #1481079: add support for HTTP_REFERER to CGIHTTPServer.
- Bug #1115886: os.path.splitext('
.
cshrc
') gives now ('
.
cshrc
', '').
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment