Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ee82c0e6
Kaydet (Commit)
ee82c0e6
authored
Eki 27, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1567274: Support SMTP over TLS.
üst
0347a9a4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
libsmtplib.tex
Doc/lib/libsmtplib.tex
+12
-0
smtplib.py
Lib/smtplib.py
+34
-5
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libsmtplib.tex
Dosyayı görüntüle @
ee82c0e6
...
@@ -28,6 +28,18 @@ For normal use, you should only require the initialization/connect,
...
@@ -28,6 +28,18 @@ For normal use, you should only require the initialization/connect,
included below.
included below.
\end{classdesc}
\end{classdesc}
\begin{classdesc}
{
SMTP
_
SSL
}{
\optional
{
host
\optional
{
, port
\optional
{
,
local
_
hostname
\optional
{
,
keyfile
\optional
{
,
certfile
}}}}}}
A
\class
{
SMTP
_
SSL
}
instance behaves exactly the same as instance
\class
{
SMTP
}
.
\class
{
SMTP
_
SSL
}
should be used for the situations where SSL is required from
the beginning of the connection and
\method
{
starttls()
}
is not appropriate.
If host is not specified, the local host is used. If port is
omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile
are also optional - they can contain a PEM formatted private key and
certificate chain file for the SSL connection.
\end{classdesc}
A nice selection of exceptions is defined as well:
A nice selection of exceptions is defined as well:
...
...
Lib/smtplib.py
Dosyayı görüntüle @
ee82c0e6
...
@@ -52,9 +52,10 @@ from sys import stderr
...
@@ -52,9 +52,10 @@ from sys import stderr
__all__
=
[
"SMTPException"
,
"SMTPServerDisconnected"
,
"SMTPResponseException"
,
__all__
=
[
"SMTPException"
,
"SMTPServerDisconnected"
,
"SMTPResponseException"
,
"SMTPSenderRefused"
,
"SMTPRecipientsRefused"
,
"SMTPDataError"
,
"SMTPSenderRefused"
,
"SMTPRecipientsRefused"
,
"SMTPDataError"
,
"SMTPConnectError"
,
"SMTPHeloError"
,
"SMTPAuthenticationError"
,
"SMTPConnectError"
,
"SMTPHeloError"
,
"SMTPAuthenticationError"
,
"quoteaddr"
,
"quotedata"
,
"SMTP"
]
"quoteaddr"
,
"quotedata"
,
"SMTP"
,
"SMTP_SSL"
]
SMTP_PORT
=
25
SMTP_PORT
=
25
SMTP_SSL_PORT
=
465
CRLF
=
"
\r\n
"
CRLF
=
"
\r\n
"
OLDSTYLE_AUTH
=
re
.
compile
(
r"auth=(.*)"
,
re
.
I
)
OLDSTYLE_AUTH
=
re
.
compile
(
r"auth=(.*)"
,
re
.
I
)
...
@@ -240,6 +241,7 @@ class SMTP:
...
@@ -240,6 +241,7 @@ class SMTP:
"""
"""
self
.
esmtp_features
=
{}
self
.
esmtp_features
=
{}
self
.
default_port
=
SMTP_PORT
if
host
:
if
host
:
(
code
,
msg
)
=
self
.
connect
(
host
,
port
)
(
code
,
msg
)
=
self
.
connect
(
host
,
port
)
if
code
!=
220
:
if
code
!=
220
:
...
@@ -271,6 +273,13 @@ class SMTP:
...
@@ -271,6 +273,13 @@ class SMTP:
"""
"""
self
.
debuglevel
=
debuglevel
self
.
debuglevel
=
debuglevel
def
_get_socket
(
self
,
af
,
socktype
,
proto
,
sa
):
# This makes it simpler for SMTP_SSL to use the SMTP connect code
# and just alter the socket connection bit.
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect:'
,
(
host
,
port
)
self
.
sock
.
connect
(
sa
)
def
connect
(
self
,
host
=
'localhost'
,
port
=
0
):
def
connect
(
self
,
host
=
'localhost'
,
port
=
0
):
"""Connect to a host on a given port.
"""Connect to a host on a given port.
...
@@ -289,16 +298,14 @@ class SMTP:
...
@@ -289,16 +298,14 @@ class SMTP:
try
:
port
=
int
(
port
)
try
:
port
=
int
(
port
)
except
ValueError
:
except
ValueError
:
raise
socket
.
error
,
"nonnumeric port"
raise
socket
.
error
,
"nonnumeric port"
if
not
port
:
port
=
SMTP_PORT
if
not
port
:
port
=
self
.
default_port
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect:'
,
(
host
,
port
)
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect:'
,
(
host
,
port
)
msg
=
"getaddrinfo returns an empty list"
msg
=
"getaddrinfo returns an empty list"
self
.
sock
=
None
self
.
sock
=
None
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
_get_socket
(
af
,
socktype
,
proto
,
sa
)
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect:'
,
sa
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect fail:'
,
msg
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect fail:'
,
msg
if
self
.
sock
:
if
self
.
sock
:
...
@@ -716,6 +723,28 @@ class SMTP:
...
@@ -716,6 +723,28 @@ class SMTP:
self
.
docmd
(
"quit"
)
self
.
docmd
(
"quit"
)
self
.
close
()
self
.
close
()
class
SMTP_SSL
(
SMTP
):
""" This is a subclass derived from SMTP that connects over an SSL encrypted
socket (to use this class you need a socket module that was compiled with SSL
support). If host is not specified, '' (the local host) is used. If port is
omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile
are also optional - they can contain a PEM formatted private key and
certificate chain file for the SSL connection.
"""
def
__init__
(
self
,
host
=
''
,
port
=
0
,
local_hostname
=
None
,
keyfile
=
None
,
certfile
=
None
):
self
.
keyfile
=
keyfile
self
.
certfile
=
certfile
SMTP
.
__init__
(
self
,
host
,
port
,
local_hostname
)
self
.
default_port
=
SMTP_SSL_PORT
def
_get_socket
(
self
,
af
,
socktype
,
proto
,
sa
):
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
if
self
.
debuglevel
>
0
:
print
>>
stderr
,
'connect:'
,
(
host
,
port
)
self
.
sock
.
connect
(
sa
)
sslobj
=
socket
.
ssl
(
self
.
sock
,
self
.
keyfile
,
self
.
certfile
)
self
.
sock
=
SSLFakeSocket
(
self
.
sock
,
sslobj
)
self
.
file
=
SSLFakeFile
(
sslobj
)
# Test the sendmail method, which tests most of the others.
# Test the sendmail method, which tests most of the others.
# Note: This always sends to localhost.
# Note: This always sends to localhost.
...
...
Misc/ACKS
Dosyayı görüntüle @
ee82c0e6
...
@@ -613,6 +613,7 @@ William Tanksley
...
@@ -613,6 +613,7 @@ William Tanksley
Christian Tanzer
Christian Tanzer
Steven Taschuk
Steven Taschuk
Amy Taylor
Amy Taylor
Monty Taylor
Tobias Thelen
Tobias Thelen
Robin Thomas
Robin Thomas
Eric Tiedemann
Eric Tiedemann
...
...
Misc/NEWS
Dosyayı görüntüle @
ee82c0e6
...
@@ -84,6 +84,8 @@ Core and builtins
...
@@ -84,6 +84,8 @@ Core and builtins
Library
Library
-------
-------
-
Patch
#
1567274
:
Support
SMTP
over
TLS
.
-
Patch
#
1560695
:
Add
.
note
.
GNU
-
stack
to
ctypes
' sysv.S so that
-
Patch
#
1560695
:
Add
.
note
.
GNU
-
stack
to
ctypes
' sysv.S so that
ctypes isn'
t
considered
as
requiring
executable
stacks
.
ctypes isn'
t
considered
as
requiring
executable
stacks
.
...
...
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