Tutorial: receiving full mail content with your Yun

I saw some tutorials on sending mails. I thought I would share how I am receiving mails with the Yun (not only the headers, which is simple). This took me quite a while to figure out.

http://myyafa.blogspot.be/search/label/4.%20Receiving%20and%20reading%20email

There might be more useful stuff on the blog besides that label.

Thanks for sharing!

It seems not easy, but I will try it.

BTW, you know whether it is possible to send a file attached to an email?

This will send a mail with attached image. Of course you could attach other file types

# Import smtplib for the actual sending function
import smtplib

# Here are the email package modules we'll need
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText


USERNAME = 'xxxxxx0@gmail.com'
PASSWORD = 'xxxxxx'
MAILTO  = 'you@yourmail.dk'


text = "Hi!\nHow are you?\nMy name is Yun, see me here:\nhttp://www.arduino.cc"

part1 = MIMEText(text, 'plain')


#reate the container (outer) email message.
msg = MIMEMultipart()
msg['Subject'] = 'Subject Attachment mail'

msg['From'] = USERNAME
msg['To'] = MAILTO
msg.preamble = 'preamble text'
msg.epilogue='Epilog text'
msg.attach(part1)

fp = open("t85.jpg", 'rb')
img = MIMEImage(fp.read(),'jpg')
fp.close()
msg.attach(img)

server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo_or_helo_if_needed()
server.starttls()
server.ehlo_or_helo_if_needed()
server.login(USERNAME,PASSWORD)
server.sendmail(USERNAME, MAILTO, msg.as_string())
server.quit()