Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Anas-jaf/554db426884b084abb3e910556413bb4 to your computer and use it in GitHub Desktop.
Save Anas-jaf/554db426884b084abb3e910556413bb4 to your computer and use it in GitHub Desktop.
fake smtp server with python

ref: http://6ftdan.com/allyourdev/2015/05/12/fake-a-smtp-server-with-python-for-rails-testing/

terminal1

➜  ~  sudo python -m smtpd -n -c DebuggingServer localhost:25
Password:
---------- MESSAGE FOLLOWS ----------
From: test@localhost.localdomain
Subject: test dayo
hello, world.
------------ END MESSAGE ------------

terminal2

➜  ~  telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 PMAC056S.local Python SMTP proxy version 0.2
HELO
501 Syntax: HELO hostname
HELO localhost
250 PMAC056S.local
MAIL FROM: test@localhost.localdomain
250 Ok
RCPT TO: test@localhost.localdomain
250 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
From: test@localhost.localdomain
Subject: test dayo
hello, world.
.
250 Ok
QUIT
221 Bye
Connection closed by foreign host.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment