Created
March 14, 2017 10:30
-
-
Save michaeltennant4554/c0ae85b50face74a1d9d41aa7b19b571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import smtplib | |
import socket | |
from email.mime.text import MIMEText | |
import datetime | |
#account info | |
to = 'RPiTime@gmail.com' | |
gmail_user = 'RPiTime@gmail.com' | |
gmail_password = '12345616' | |
smtpserver = smtplib.SMTP('smtp.gmail.com', 587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.login(gmail_user, gmail_password) | |
today = datetime.date.today() | |
arg='ip route list' | |
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE) | |
data=p.communicate() | |
split_data=data[0].split() | |
ipaddr=split_data[split_data.index('src')+1] | |
my_ip='Good day human overlord. This is your humble pi. My ip today is %s' % ipaddr | |
msg=MIMEText(my_ip) | |
msg['Subject']= 'Rpi2 Reporting in!' | |
msg['From']= gmail_user | |
msg['To'] = to | |
smtpserver.sendmail(gmail_user, [to], msg.as_string()) | |
smtpserver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment