Debug SMTP server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Start a debug SMTP server using Python's smtpd module | |
show() { | |
echo 1>&2 "$@" | |
} | |
port=${1-25} | |
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 | |
fi | |
fi | |
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