Skip to content

Instantly share code, notes, and snippets.

@Xion
Last active January 1, 2016 11:19
Show Gist options
  • Save Xion/8136917 to your computer and use it in GitHub Desktop.
Save Xion/8136917 to your computer and use it in GitHub Desktop.
Debug SMTP server
#!/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