Super simple mailsink with Python

If your script or app sends  mail and you’ve got no time or don’t feel like configuring a real SMTP server, use a mailsink. A debugging method that in it’s simplest form just displays the result of the SMTP conversation, namely the message.

Fire up a terminal an run this code:

python -m smtpd -n -c DebuggingServer localhost:3000

This listens on port 3000 on your localhost (127.0.0.1). If you need port 25 (the SMTP default port), just run the line with sudo and enter your password:

sudo python -m smtpd -n -c DebuggingServer localhost:25

That’s it. Enjoy.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)