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
6730f26c
Commit
6730f26c
authored
Mar 24, 2002
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add local_hostname option to SMTP.__init__. If supplied, it is used
as the fully qualified local hostname.
parent
03f3ee6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Lib/smtplib.py
Lib/smtplib.py
+10
-10
No files found.
Lib/smtplib.py
View file @
6730f26c
...
...
@@ -220,13 +220,15 @@ class SMTP:
ehlo_resp = None
does_esmtp = 0
def __init__(self, host = '', port = 0):
def __init__(self, host = '', port = 0
, local_hostname = None
):
"""
Initialize
a
new
instance
.
If
specified
,
`
host
' is the name of the remote host to which to
connect. If specified, `port'
specifies
the
port
to
which
to
connect
.
By
default
,
smtplib
.
SMTP_PORT
is
used
.
An
SMTPConnectError
is
raised
if
the
specified
`
host
' doesn'
t
respond
correctly
.
if
the
specified
`
host
' doesn'
t
respond
correctly
.
If
specified
,
`local_hostname`
is
used
as
the
FQDN
of
the
local
host
.
By
default
,
the
local
hostname
is
found
using
gethostbyname
().
"""
self.esmtp_features = {}
...
...
@@ -234,6 +236,10 @@ class SMTP:
(code, msg) = self.connect(host, port)
if code != 220:
raise SMTPConnectError(code, msg)
if local_hostname:
self.local_hostname = local_hostname
else:
self.local_hostname = socket.getfqdn()
def set_debuglevel(self, debuglevel):
"""
Set
the
debug
output
level
.
...
...
@@ -356,10 +362,7 @@ class SMTP:
Hostname to send for this command defaults to the FQDN of the local
host.
"""
if
name
:
self
.
putcmd
(
"helo"
,
name
)
else
:
self
.
putcmd
(
"helo"
,
socket
.
getfqdn
())
self
.
putcmd
(
"helo"
,
name
or
self
.
local_hostname
)
(
code
,
msg
)
=
self
.
getreply
()
self
.
helo_resp
=
msg
return
(
code
,
msg
)
...
...
@@ -370,10 +373,7 @@ class SMTP:
host.
"""
self
.
esmtp_features
=
{}
if
name
:
self
.
putcmd
(
"ehlo"
,
name
)
else
:
self
.
putcmd
(
"ehlo"
,
socket
.
getfqdn
())
self
.
putcmd
(
"ehlo"
,
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
...
...
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