The Python Oracle

aiosmtpd - python smtp server

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open

--

Chapters
00:00 Aiosmtpd - Python Smtp Server
01:32 Accepted Answer Score 6
02:40 Thank you

--

Full question
https://stackoverflow.com/questions/4402...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #smtp #smtplib #aiosmtpd

#avk47



ACCEPTED ANSWER

Score 6


In your code, Controller(Sink(), hostname='::0', port=8025) starts an SMTP server that receives messages on port 8025 and throws them away (the Sink() part). That's why the messages don't show up in your inbox -- when you send an email to localhost:8025, it is never actually sent to your inbox.

aiosmtpd is an SMTP server, meaning it will receive messages sent via SMTP and process them somehow. In your code, the Sink() handler does not process incoming email in any way -- it simply throws incoming messages away.

If you want to send email over the Internet to bob@hate.com, then you should contact the SMTP server responsible for the hate.com domain instead of the SMTP server you're running using aiosmtpd. For this task you will not need to run an SMTP server, since there's supposedly already an SMTP server on the internet running for hate.com; instead, you will need an SMTP client component, which is provided in the smtplib module in the Python standard library. Sending email with SMTP is not something that aiosmtpd is involved with in any way, and you should look for how to use smtplib instead.

Further reading: Email ยง Operation on Wikipedia.