
In this tutorial we will send an email with the ESP32 card when a push button is pressed.
You must use an SMTP server that allows you to send an email through the ESP32 card.
Pushbutton
To perform the assembly, you can connect
the first tab of the push button at pin D21 of the ESP32 board
the second leg of the GND pushbutton on the ESP32 board
Note: you must import the two libraries: ConnectWifi.py and umail.py.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from machine import Pin button = Pin(21, Pin.IN, Pin.PULL_UP) import ConnectWifi ConnectWifi.connect() import umail while True: if not button.value(): #We press the button smtp = umail.SMTP('smtp.gmail.com', 587, username='adresse-émtteur@gmail.com', password='*********') smtp.to('adresse_recepteur@gmail.com') smtp.send("Message envoyé par la carte ESP32") smtp.quit() |
Ingo 06-05-2222
Hi! You've programmed a great and flexible solution. Would it be possible to include the subject and the Sender-name into the e-Mail script "umail"? Thank you