diff --git a/micromail.py b/micromail.py index 17cec66..84ac399 100644 --- a/micromail.py +++ b/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