Fix STARTTLS handling and improve logging in MicromailClient

This commit is contained in:
Edgar P. Burkhart 2025-05-17 21:35:50 +02:00
parent 8487456da1
commit 6f336c17c0
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -58,9 +58,10 @@ class MicromailClient:
sys.exit(1)
self.features = self.ehlo()
print(self.features)
if self.starttls and "STARTTLS" in self.features:
self.starttls()
if self.starttls and b"STARTTLS" in self.features:
self.start_starttls()
def login(self, username, password):
self.username = username
@ -122,12 +123,13 @@ class MicromailClient:
sys.exit(1)
return res
def starttls(self):
def start_starttls(self):
code, res = self.send_command(b"STARTTLS")
if code != b"220":
print(f"Error: got code {code} on STARTTLS")
sys.exit(1)
print(res)
self.socket = ssl.wrap_socket(self.socket)
def new_message(self, to, sender=None):