Can't send mail using Outlook (OS Error)
Vultik opened this issue · 2 comments
I have not succeed to send mail using outlook. It works great with Gmail though.
I'm using MicroPython v1.19.1 on ESP32.
Here my code :
import umail
SMTP_PORT = 587
SMTP_HOST = "smtp.office365.com"
SMTP_USERNAME = "xxxx@outlook.com"
SMTP_PASSWORD = "xxx"
WIFI_AP_SSID = "xxx-ap"
WIFI_AP_PASSWORD = "xxx"
def do_connect():
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(WIFI_AP_SSID, WIFI_AP_PASSWORD)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
if __name__ == "__main__":
do_connect()
smtp = umail.SMTP(host=SMTP_HOST, port=SMTP_PORT, ssl=True, username=SMTP_USERNAME, password=SMTP_PASSWORD)
smtp.to('noreply@example.com')
smtp.send("Hello ?")
smtp.quit()
If i'm not using SSL, there is no error, but i don't receive the mail (maybe it's a different SMTP port)
Looks like Outlook.com only supports STARTSSL protocol.
STARTSSL protocol usually means first connect in plaintext; upon server's request, wrap the connection with SSL encryption.
So you should not need to specify ssl=True
in your code, SSL session will start (upon server's request) regardless of your initial setting.
Ok,
I thought that it doesn't work without SSL, but the mail was in the spam ...
I think it will be great to add some features like :
- add mail object
- add encoding support : it doesn't work with utf-8 char
- add html support
- add attachment support
Thanks for this minimal great uPython lib !