Set default port values in MicromailClient constructor based on SSL and STARTTLS settings
This commit is contained in:
parent
36dc32fef3
commit
4c9ff09ea9
1 changed files with 10 additions and 2 deletions
12
micromail.py
12
micromail.py
|
@ -6,9 +6,8 @@ from datetime import datetime, timedelta, timezone
|
|||
|
||||
|
||||
class MicromailClient:
|
||||
def __init__(self, host, port, ssl=False, starttls=False):
|
||||
def __init__(self, host, port=0, ssl=False, starttls=False):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
if ssl and starttls:
|
||||
raise Error("Cannot use both SSL and STARTTLS at the same time.")
|
||||
|
@ -16,6 +15,15 @@ class MicromailClient:
|
|||
self.ssl = ssl
|
||||
self.starttls = starttls
|
||||
|
||||
if port == 0:
|
||||
if ssl:
|
||||
port = 465
|
||||
elif starttls:
|
||||
port = 587
|
||||
else:
|
||||
port = 25
|
||||
self.port = port
|
||||
|
||||
self.socket = None
|
||||
self.username = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue