I am using an ESP32 and trying to send emails through it. I am using the following code provided in this post viewtopic.php?f=11&t=1047&start=10
to = 'recipient@mail.com'
gmail_user = 'some.user@gmail.com'
gmail_pwd = 'password'
smtpserver = smtplib.SMTP("smtp.gmail.com", 465)
smtpserver.helo()
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject: Email from the WiPy \n'
msg = header + '\n Hi, \n this is The WiPy emailing \n\n Cheers, \n The WiPy'
smtpserver.sendmail(gmail_user, to, msg)
smtpserver.close()
Also I am using the smtplib library provided there, the users there say it works, however I get the following error
Traceback (most recent call last):
File "<stdin>", line 19, in <module>
File "smtplib.py", line 84, in __init__
File "smtplib.py", line 110, in connect
AttributeError: 'module' object has no attribute 'IPPROTO_SEC'
Which basically happens when trying to create de smtplib.SMTP object. What is the problem here?
Sending email with ESP32
Re: Sending email with ESP32
A bit out of date. But this question has been bothering me recently.
But it may help in the future. I hopemail is sent using the SMTP protocol. There are libraries and examples, and the basic protocol isn't too difficult to implement.
But it's not that simple, most SMTP servers won't accept mail from a simple SMTP client implementation. They require authentication and TLS encryption. That makes it harder.
Probably better to use MQTT, and let a cloud-based MQTT broker handle sending the email. I using best solustion for SMTP mailing here - https://www.atompark.com/smtp-service/
Regards Jonwalter
But it may help in the future. I hopemail is sent using the SMTP protocol. There are libraries and examples, and the basic protocol isn't too difficult to implement.
But it's not that simple, most SMTP servers won't accept mail from a simple SMTP client implementation. They require authentication and TLS encryption. That makes it harder.
Probably better to use MQTT, and let a cloud-based MQTT broker handle sending the email. I using best solustion for SMTP mailing here - https://www.atompark.com/smtp-service/
Regards Jonwalter
Re: Sending email with ESP32
It is completely fine. At the end of the day I managed doing it with services like IFTT. Either way thanks for the reply