Skip to content

Instantly share code, notes, and snippets.

Last active January 1, 2016 11:19
What would you like to do?
Debug SMTP server
# Start a debug SMTP server using Python's smtpd module
show() {
echo 1>&2 "$@"
smtpd_args="-c DebuggingServer localhost:$port"
if [ $(whoami) != "root" ]; then
smtpd_args="-n $smtpd_args"
if [ $port -lt 1024 ]; then
show "Listening on TCP port below 1024 requires root."
show "Did you mean \`sudo $0\`?"
exit 1
show "Running on port $port..."
python -m smtpd $smtpd_args
show "Terminated."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment