Last active
September 8, 2015 08:54
-
-
Save michaelsarduino/f12e330af7bb919bde78 to your computer and use it in GitHub Desktop.
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 characters
import time | |
import serial | |
import smtplib | |
TO = 'EMPFAENGER HIER EINGEBEN' | |
GMAIL_USERNAME = 'ABSENDER HIER EINGEBEN' | |
GMAIL_PASSWORD = 'PASSWORT ABSENDER HIER EINGEBEN' | |
BETREFF = 'Arduino' | |
TEXT = 'Hier den Email Text eingeben' | |
arduino = serial.Serial('COM3', 9600) | |
def email_senden(): | |
print("Sende Email") | |
smtpserver = smtplib.SMTP("smtp.gmail.com",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
smtpserver.login(GMAIL_USERNAME, GMAIL_PASSWORD) | |
header = 'To:' + TO + '\n' + 'From: ' + GMAIL_USERNAME | |
header = header + '\n' + 'Subject:' + BETREFF + '\n' | |
print header | |
msg = header + '\n' + TEXT + ' \n\n' | |
smtpserver.sendmail(GMAIL_USERNAME, TO, msg) | |
smtpserver.close() | |
while True: | |
empfangen = arduino.readline() | |
print(empfangen) | |
if empfangen[0] == '1' : | |
email_senden() | |
time.sleep(0.5) | |
empfangen = '0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment