Sending email to a list of users using mailx in subprocess

63 views Asked by At

This code works to send email to a single or more users:

msg="My text message"
p1=subprocess.run(["echo",msg],stdout=subprocess.PIPE)
subprocess.run(["mailx -s 'Subject: Hive Alert' '[email protected]' '[email protected]'< /dev/stdin"],stdout=subprocess.PIPE,input=p1.stdout,shell=True)

I have a python list

users=['[email protected]', '[email protected]', '[email protected]', '[email protected]']

How do I send email to a python list by modifying the above code or any other code using mailx in subprocess?

TIA Shari

0

There are 0 answers