Running on a Linux system. I have a executable .jar file that I am trying to make the output into the body of a email that I am having my python program send. However, though this program executes, the email is received with nothing in the body. So the output of the .jar is lost in the subprocess.
import smtplib
import subprocess
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.ehlo()
# login cred
username='Sample@gmail.com'
password='password'
s.login(username,password)
# email objects
replyto='sample@sample.com'
sendto=['export@sample.com']
sendtoShow='sample@sample.com'
subject='Example Subject'
content=subprocess.run(['java', '-jar', 'Example.jar'], stdout=subprocess.PIPE)
mailtext='From: '+replyto+'\r\nTo: '+sendtoShow+'\r\n'
mailtext=mailtext+'Subject:'+subject+'\r\n\r\n'+content.stdout.decode("utf-8")
s.sendmail(replyto, sendto, mailtext)
rslt=s.quit()
print('Sendmail result=' + str(rslt[1]))
Problem solved and reflected above.