From d96c86004eec49d6dc6e8b0585bef828af2cdce5 Mon Sep 17 00:00:00 2001 From: tligui_y Date: Thu, 31 Jul 2025 11:49:13 +0200 Subject: [PATCH] Update tests/test_utils_sendmail.py --- tests/test_utils_sendmail.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/test_utils_sendmail.py b/tests/test_utils_sendmail.py index 2e6f1dbb7..85419efcd 100644 --- a/tests/test_utils_sendmail.py +++ b/tests/test_utils_sendmail.py @@ -53,11 +53,34 @@ def test_sendmail_mime_format_to_file(): os.remove(script_path) ''' -def test_sendmail_real_local(): - to_addr = f"yasmine.tligui@psi.ch" +import subprocess + +def test_sendmail_real_local_verbose(): + to_addr = "yasmine.tligui@psi.ch" subject = "Test mail from pytest" body = "Hello! This is a real test sent using local sendmail." - print(shutil.which("sendmail")) - sendmail(to_addr, subject=subject, body=body) + + message = f"""Subject: {subject} +From: test@localhost +To: {to_addr} + +{body} +""" + + print("=== SENDING MAIL ===") + process = subprocess.Popen( + ["/usr/sbin/sendmail", "-v", to_addr], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + stdout, stderr = process.communicate(message.encode()) + + print("\n=== SENDMAIL STDOUT ===") + print(stdout.decode()) + + print("\n=== SENDMAIL STDERR ===") + print(stderr.decode()) + \ No newline at end of file