Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Beaglebone Python Programming

You're reading from   Learning Beaglebone Python Programming Unleash the potential of BeagleBone using Python

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781784399702
Length 196 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexander C Hiam Alexander C Hiam
Author Profile Icon Alexander C Hiam
Alexander C Hiam
Arrow right icon
View More author details
Toc

SMTP


We've looked at various forms of displays that you can attach to your BeagleBone, but those are only useful when you're looking at it. If your BeagleBone is not accessible, for instance, it's monitoring something at your home while you're out, you might still need a way for it to send you information. One simple way to achieve this is to use Simple Mail Transfer Protocol (SMTP) to send e-mails from your BeagleBone. Save this code to a new file called email_sender.py by filling in your account's SMTP details:

import smtplib
from email.mime.text import MIMEText

SMTP_host = 'smtp.gmail.com'
SMTP_email = 'username@gmail.com'
SMTP_pass = 'password'

def send_email(to, subject, body):
  msg = MIMEText(body)
  msg['Subject'] = subject
  msg['From'] = SMTP_email
  msg['To'] = to
  server = smtplib.SMTP_SSL(SMTP_host)
  server.login(SMTP_email, SMTP_pass)
  server.sendmail(SMTP_email, to, msg.as_string())

Note

Just like with IMAP, to retrieve e-mails, SMTP is a standard protocol and is used by...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image