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