31.07.2015 Views

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

61 | Connecting <strong>to</strong> <strong>the</strong> Outside WorldConnecting <strong>to</strong> <strong>the</strong> Outside WorldNote: At <strong>the</strong> time of this guide’s publication, it was not possible for <strong>the</strong> following three projects <strong>to</strong> becarried out using <strong>the</strong> NSW DEC network as <strong>the</strong>re were not sufficient ports open for communication.Sending Email from your <strong>Galileo</strong>OverviewThis activity sends an email from your <strong>Galileo</strong> when you run <strong>the</strong> program. It makes use of <strong>the</strong>Simple Mail Transfer Pro<strong>to</strong>col (SMTP) <strong>to</strong> send <strong>the</strong> email. The SMTP pro<strong>to</strong>col is <strong>the</strong> pro<strong>to</strong>col usedby <strong>the</strong> majority of all mails that are transferred around <strong>the</strong> internet. Here are a couple of linksabout how SMTP works:http://www.ballisticdomains.com/articles/art-web-hosting/138-smtp-servershttp://www.laynetworks.com/smtp.htmMaterials»»1 x <strong>Intel</strong>® <strong>Galileo</strong> Gen 2 board»»1 x 12V Power supply»»1 x Micro USB leadCoding1. Connect up <strong>to</strong> your <strong>Galileo</strong> using Putty or Terminal.2. From <strong>the</strong> Linux console, using <strong>the</strong> vi edi<strong>to</strong>r, copy and paste <strong>the</strong> following code in<strong>to</strong> a filecalled SendEmailOnBut<strong>to</strong>nPress.py3. Run <strong>the</strong> program from <strong>the</strong> command prompt by typing in:4. root@clan<strong>to</strong>n~# python SendEmailOnBut<strong>to</strong>nPress.py5. Press <strong>the</strong> but<strong>to</strong>n and an email should be sent.import smtplibFROM='Sarahs<strong>Galileo</strong>@gmail.com' # can be a fake email addressTO=[recipient1@email.com, recipient2@email.com,]SUBJECT="I am alive"TEXT="This is from <strong>the</strong> <strong>Galileo</strong>"#Prepare actual messagemessage = """\From: %sTo: %sSubject: %s%s

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!