This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user