Guest User

Untitled

a guest
Oct 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import subprocess
  2. import smtplib
  3. import socket
  4. from email.mime.text import MIMEText
  5. import datetime
  6. # Change to your own account information
  7. to = 'xxxxxxxxxx@gmail.com' # Sending email
  8. gmail_user = 'xxxxxxxxxxxxx@gmail.com' Senders email
  9. gmail_password = 'xxxxxxxx' senders Email password
  10. smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
  11. smtpserver.ehlo()
  12. smtpserver.starttls()
  13. smtpserver.ehlo
  14. smtpserver.login(gmail_user, gmail_password)
  15. today = datetime.date.today()
  16. # Very Linux Specific
  17. arg='ip route list'
  18. p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
  19. data = p.communicate()
  20. split_data = data[0].split()
  21. ipaddr = split_data[split_data.index('src')+1]
  22.  
  23.  
  24. my_ip = 'This is the massage %s' % today.strftime('%b %d %Y')
  25.  
  26.  
  27.  
  28.  
  29.  
  30. msg = MIMEText(my_ip)
  31. msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y')
  32. msg['From'] = gmail_user
  33. msg['To'] = to
  34. smtpserver.sendmail(gmail_user, [to], msg.as_string())
  35. smtpserver.quit()
Add Comment
Please, Sign In to add comment