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
48305667
Commit
48305667
authored
Dec 06, 2009
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logging: Added optional 'secure' parameter to SMTPHandler.
parent
42d63847
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
Lib/logging/handlers.py
Lib/logging/handlers.py
+10
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/logging/handlers.py
View file @
48305667
...
...
@@ -809,7 +809,8 @@ class SMTPHandler(logging.Handler):
"""
A handler class which sends an SMTP email for each logging event.
"""
def
__init__
(
self
,
mailhost
,
fromaddr
,
toaddrs
,
subject
,
credentials
=
None
):
def
__init__
(
self
,
mailhost
,
fromaddr
,
toaddrs
,
subject
,
credentials
=
None
,
secure
=
False
):
"""
Initialize the handler.
...
...
@@ -817,7 +818,9 @@ class SMTPHandler(logging.Handler):
line of the email. To specify a non-standard SMTP port, use the
(host, port) tuple format for the mailhost argument. To specify
authentication credentials, supply a (username, password) tuple
for the credentials argument.
for the credentials argument. To specify the use of a secure
protocol (TLS), pass in True for the secure argument. This will
only be used when authentication credentials are supplied.
"""
logging
.
Handler
.
__init__
(
self
)
if
isinstance
(
mailhost
,
tuple
):
...
...
@@ -833,6 +836,7 @@ class SMTPHandler(logging.Handler):
toaddrs
=
[
toaddrs
]
self
.
toaddrs
=
toaddrs
self
.
subject
=
subject
self
.
secure
=
secure
def
getSubject
(
self
,
record
):
"""
...
...
@@ -884,6 +888,10 @@ class SMTPHandler(logging.Handler):
self
.
getSubject
(
record
),
formatdate
(),
msg
)
if
self
.
username
:
if
self
.
secure
:
smtp
.
ehlo
()
smtp
.
starttls
()
smtp
.
ehlo
()
smtp
.
login
(
self
.
username
,
self
.
password
)
smtp
.
sendmail
(
self
.
fromaddr
,
self
.
toaddrs
,
msg
)
smtp
.
quit
()
...
...
Misc/NEWS
View file @
48305667
...
...
@@ -507,6 +507,9 @@ Core and Builtins
Library
-------
- logging: Added optional `secure` parameter to SMTPHandler, to enable use of
TLS with authentication credentials.
- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is
generated in Distutils. Patch by Stephen Emslie.
...
...
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