Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email Alerts! #1

Open
Meteodeep opened this issue Mar 18, 2017 · 2 comments
Open

Email Alerts! #1

Meteodeep opened this issue Mar 18, 2017 · 2 comments
Assignees

Comments

@Meteodeep
Copy link
Contributor

Meteodeep commented Mar 18, 2017

No description provided.

@Meteodeep Meteodeep self-assigned this Mar 19, 2017
@Meteodeep
Copy link
Contributor Author

import smtplib server = smtplib.SMTP(‘smtp.gmail.com’, 587) server.starttls() server.login(“[email protected]“, “FromUserPassword“) msg = “This is a simple email test!” server.sendmail(“[email protected]“, “[email protected]“, msg) server.quit()

@Meteodeep
Copy link
Contributor Author

Meteodeep commented Mar 19, 2017

New Code:
import subprocess import smtplib import socket from email.mime.text import MIMEText import datetime #account info to = '[email protected]' gmail_user = '[email protected]' gmail_password = '123456' 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant