I have the below Python code for sending an e-mail to my ID from the contents of file filename
. I am trying to send the email with the text color-formatted.
Any ideas please advise.
def ps_Mail():
filename = "/tmp/ps_msg"
f = file(filename)
if os.path.exists(filename) and os.path.getsize(filename) > 0:
mailp = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
msg = MIMEMultipart('alternative')
msg['To'] = "karn@abc.com"
msg['Subject'] = "Uhh!! Unsafe rm process Seen"
msg['From'] = "psCheck@abc.com"
msg1 = MIMEText(f.read(), 'text')
msg.attach(msg1)
mailp.communicate(msg.as_string())
ps_Mail()
"+f.read()+"
", 'html')` – Daniel R. Livingston Jun 02 '17 at 07:19