Skip to content

Instantly share code, notes, and snippets.

@BrianHicks
Created March 13, 2014 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianHicks/9528321 to your computer and use it in GitHub Desktop.
Save BrianHicks/9528321 to your computer and use it in GitHub Desktop.

Fakemail

Fakemail provides a fake SMTP server for use in developing applications which rely on sending email. This works especially well for clients like Flask-Mail which do not have a "debug" mode to just print the mail to stdout.

The provided Procfile demonstrates how to run the server - in this particular case if you set your application to send to $MAIL_PORT this process will follow suit if it is set, and otherwise will connect on port 4467 (as used in the inbox.py samples.)

Fakemail depends on Kenneth Reitz's Inbox.py, but has no other dependencies.

from inbox import Inbox
inbox = Inbox()
@inbox.collate
def handle(to, sender, body):
print '*' * 40
print 'Sender:\t{}'.format(sender)
print 'To:\t{}'.format(to)
print '-' * 10
print body
print
if __name__ == '__main__':
inbox.dispatch()
fakemail: python fakemail.py localhost ${MAIL_PORT:-4467}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment