Read email from a system pipe into python

602 0

#!/usr/local/bin/python

import sys
import email

full_msg = “”
for line in sys.stdin
full_msg += line

msg = email.message_from_string(full_msg)

to = msg[‘to’]
fromwho = msg[‘from’]
subject = msg[‘subject’]

#make an emty variable for email body
body = “”

#if the message contains attaachments find the body attachment
#if not find the entire emial body
if msg.is_multipart():
for payload in msg.get_payload():
# if payload.is_multipart(): …
body = payload.get_payload()
else:
body = msg.get_payload()

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Related Post

GPS RESPONSE CODE ORDER

Posted by - October 18, 2015 0
in response to AT+CGPSINF=0 0 longitude 1 latitude 2 altitude 3 UTC Broadcast Time 4 TTFF Time To First Fix…

Wire camera to pi

Posted by - October 24, 2015 0
Install camera software & configure pi One picture program One picture per blink cycle Print proto time on picture  …

Add Clock Via i2c

Posted by - October 24, 2015 0
Prepare i2c added real time clock driver to raspian Add time variable to picture display Solder pins to clock module…

python to send a SMS message

Posted by - October 18, 2015 0
[crayon-59760d3cde9aa740264141/] Keep Reading : Serial Communication with SMS Modem (FONA) GPS RESPONSE CODE ORDER Serial Commands used by our Satellite…

Leave a comment

Your email address will not be published. Required fields are marked *