Update tests/test_utils_sendmail.py
Run CI Tests / test (push) Successful in 2m47s

This commit is contained in:
2025-07-31 11:49:13 +02:00
parent cd288e9583
commit d96c86004e
+27 -4
View File
@@ -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())