Read email from a system pipe into python

3089 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()

Facebooktwitterredditpinterestlinkedinmail

Related Post

LED Blinking

Posted by - August 15, 2015 0
You will need the following things: Raspberry pi configured (see previos lessons) 5 Volt LED bulb(s) 2 jumper wires m/f…

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  …

python to send a SMS message

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

Serial Commands used by our Satellite transciever.

Posted by - October 17, 2015 0
We will need the crc16 python code library : http://code.google.com/p/pycrc16/downloads [crayon-67ed599c1e41f628033065/] [crayon-67ed599c1e426790746798/]   [crayon-67ed599c1e429315499898/] Keep Reading : Serial Communication with…

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.