-
-
Save mattbk/f2373c4996d9dace6693 to your computer and use it in GitHub Desktop.
Revisions
-
mattbk revised this gist
Feb 20, 2016 . 1 changed file with 12 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,19 +5,26 @@ from email.mime.text import MIMEText import datetime # Change to your own account information to = 'TO@gmail.com' gmail_user = 'YOU@gmail.com' gmail_password = 'PASSWORD' smtpserver = smtplib.SMTP('smtp.gmail.com', 587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(gmail_user, gmail_password) today = datetime.date.today() # Very Linux Specific 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_network_ip = 'Network IP: %s' % ipaddr #http://stackoverflow.com/a/9481595/2152245 from urllib2 import urlopen my_public_ip = '\nPublic IP: %s' % urlopen('http://ip.42.pl/raw').read() msg = MIMEText(my_network_ip+my_public_ip) msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y') msg['From'] = gmail_user msg['To'] = to -
mattbk revised this gist
Feb 20, 2016 . 1 changed file with 2 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # https://gist.github.com/johnantoni/8199088 import subprocess import smtplib import socket @@ -13,13 +14,7 @@ smtpserver.ehlo smtpserver.login(gmail_user, gmail_password) today = datetime.date.today() #http://stackoverflow.com/a/9481595/2152245 from urllib2 import urlopen my_ip = urlopen('http://ip.42.pl/raw').read() msg = MIMEText(my_ip) -
mattbk revised this gist
Feb 20, 2016 . No changes.There are no files selected for viewing
-
mattbk renamed this gist
Feb 20, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,9 @@ data = p.communicate() split_data = data[0].split() ipaddr = split_data[split_data.index('src')+1] #my_ip = 'Your ip is %s' % ipaddr from urllib2 import urlopen my_ip = urlopen('http://ip.42.pl/raw').read() msg = MIMEText(my_ip) msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y') msg['From'] = gmail_user -
johnantoni created this gist
Dec 31, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import subprocess import smtplib import socket from email.mime.text import MIMEText import datetime # Change to your own account information to = '[email protected]' gmail_user = '[email protected]' gmail_password = 'yourpassword' smtpserver = smtplib.SMTP('smtp.gmail.com', 587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(gmail_user, gmail_password) today = datetime.date.today() # Very Linux Specific 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 = 'Your ip is %s' % ipaddr msg = MIMEText(my_ip) msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y') msg['From'] = gmail_user msg['To'] = to smtpserver.sendmail(gmail_user, [to], msg.as_string()) smtpserver.quit()