diff --git a/proxy_server.py b/proxy_server.py index 77e7a27..c599546 100644 --- a/proxy_server.py +++ b/proxy_server.py @@ -344,7 +344,7 @@ class SMTPProxyHandler: await asyncio.to_thread(self.send_message, envelope.mail_from, envelope.rcpt_tos, envelope.content) return "250 Message accepted for delivery" - def send_message(self, sender, recipients, data): + def send_message(self, sender, recipients, data): """Forward a complete SMTP message to the backend SMTP server.""" message = data.decode("utf-8", errors="replace") if Settings.BACKEND_SMTP_USE_SSL: diff --git a/requirements.txt b/requirements.txt index 595c94e..0bc8eef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -aiosmtpd>=1.6.3 +aiosmtpd>=1.4.6,<1.5 pytest>=8.0.0 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..ccb70b5 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,7 @@ +import os +import sys + +# Ensure the project root is on sys.path when running tests. +ROOT = os.path.dirname(os.path.dirname(__file__)) +if ROOT not in sys.path: + sys.path.insert(0, ROOT) diff --git a/tests/test_proxy_server.py b/tests/test_proxy_server.py index 02f349b..bb2cfab 100644 --- a/tests/test_proxy_server.py +++ b/tests/test_proxy_server.py @@ -114,7 +114,7 @@ def test_smtp_proxy_handler_forwards_message_over_ssl(monkeypatch): assert captured["instance"].logged_in is True assert captured["instance"].sent[0] == "from@example.com" assert captured["instance"].sent[1] == ["to@example.com"] - assert b"Subject: Test" in captured["instance"].sent[2] + assert "Subject: Test" in captured["instance"].sent[2] Settings.BACKEND_SMTP_USE_SSL = previous_ssl Settings.BACKEND_SMTP_USER = previous_user