NEW (third party):
pip install aiosmtpd python -m aiosmtpd -n -l localhost:1025
python -m smtpd -n -c DebuggingServer localhost:1025
Deprecated since version 3.6, will be removed in version 3.12: The smtpd module is deprecated (see PEP 594 for details). The aiosmtpd package is a recommended replacement for this module. It is based on asyncio and provides a more straightforward API.