Skip to content

Instantly share code, notes, and snippets.

@aurorapar
Created March 29, 2018 22:10
Show Gist options
  • Save aurorapar/1c567356062e29a3b865d943d695ce5e to your computer and use it in GitHub Desktop.
Save aurorapar/1c567356062e29a3b865d943d695ce5e to your computer and use it in GitHub Desktop.
Email IP
# Import smtplib for the actual sending function
import smtplib, sys, os
# Import the email modules we'll need
from email.mime.text import MIMEText
MY_ADDRESS = '[email protected]'
PASSWORD = '<EMAIL PASSWORD>'
message = 'Your network settings are: '
for x in sys.argv:
if x != sys.argv[0]:
message += x + ' '
msg = MIMEText(message)
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'Raspberry Connection Info'
msg['From'] = MY_ADDRESS
msg['To'] = MY_ADDRESS
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP(host='smtp.gmail.com', port=587)
s.ehlo()
s.starttls()
s.login(MY_ADDRESS, PASSWORD)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
ip=`ifconfig wlan0`
python emailip.py $ip
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
post-up /home/pi/emailip.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment