View difference between Paste ID: F5taJcca and A72qJSgv
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/python
2
import subprocess
3
import smtplib
4
import socket
5
from email.mime.text import MIMEText
6
import datetime
7
# Change to your own account information
8
to = '[email protected]'
9
gmail_user = '[email protected]'
10
gmail_password = 'alanarteche'
11
smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
12
smtpserver.ehlo()
13
smtpserver.starttls()
14
smtpserver.ehlo
15
smtpserver.login(gmail_user, gmail_password)
16
today = datetime.date.today()
17
# Very Linux Specific
18
arg='ip route list'
19
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
20
data = p.communicate()
21
split_data = data[0].split()
22
ipaddr = split_data[split_data.index('src')+1]
23
my_ip = 'Your ip is %s' %  ipaddr
24
msg = MIMEText(my_ip)
25
msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y')
26
msg['From'] = gmail_user
27
msg['To'] = to
28
smtpserver.sendmail(gmail_user, [to], msg.as_string())
29
smtpserver.quit()