I'm trying to send mail on an event trigger from python on a linux server. The server already has mail installed and I have my code like so:
import subprocess
subprocess.call(["mail","-s Hello there", "[email protected] <
this_text_document.txt"])
Feel as if I am blind as a bat here. Receive perpetual loading. Upon interrupt receive this: "No recipients specified ... message not sent" Please send help.
this will work:
def SendMail(Subject: str, Body: str):
body_str_encoded_to_byte = Body.encode()
return_stat = subprocess.run([f"mail", f"-s {Subject}", "[email protected]"], input=body_str_encoded_to_byte)
print(return_stat)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With