DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • DevOps Midwest: A Community Event Full of DevSecOps Best Practices
  • Front-End: Cache Strategies You Should Know
  • Payments Architecture - An Introduction
  • Using Render Log Streams to Log to Papertrail

Trending

  • DevOps Midwest: A Community Event Full of DevSecOps Best Practices
  • Front-End: Cache Strategies You Should Know
  • Payments Architecture - An Introduction
  • Using Render Log Streams to Log to Papertrail
  1. DZone
  2. Data Engineering
  3. Databases
  4. Debug SMTP Server One-Liner

Debug SMTP Server One-Liner

Mikko Ohtamaa user avatar by
Mikko Ohtamaa
·
Apr. 27, 13 · Interview
Like (0)
Save
Tweet
Share
7.62K Views

Join the DZone community and get the full member experience.

Join For Free

If you are doing web development there is often a need to emulate and intercept outgoing email. Email delivery is handled by SMTP protocol. Production and staging server have fixed SMTP servers available in their network. However, this is not often the case for your development laptop, especially if you tend to do development in different networks (places).

Python comes with simple smtpd module which allows you to run a simple SMTP server easily. When doing email debugging, smtpd has extreme useful DebuggingServer feature making it dump all relayed email to stdout instead of relaying them forward for email delivery. This approach is compatible on all platforms: Windows, OSX and Linux.

Non-root way to run debugging SMTP server. You need to change the SMTP server details in your application settings to localhost:1025:

python -m smtpd -n -c DebuggingServer localhost:1025

If you want to bind SMTP port 25 you need to run this as a root:

sudo python -m smtpd -n -c DebuggingServer localhost:25

Now, when your application sends email it is printed to terminal running debugging smtpd:

---------- MESSAGE FOLLOWS ----------
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [example.com] Confirm your email
From: test@example.com
To: mikko@example.com
Date: Fri, 26 Apr 2013 07:20:34 -0000
Message-ID: <20130426072034.83439.2762@Kohr-Ah.local>
X-Peer: 127.0.0.1

Test output from smtpd
------------ END MESSAGE ------------

Alternative you can go for a full stack solution and install Postfix with external authenticating mail server.

Debug (command) Web development application Delivery (commerce) Network Python (language) Mail (Apple) Production (computer science) terminal Protocol (object-oriented programming)

Published at DZone with permission of Mikko Ohtamaa, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • DevOps Midwest: A Community Event Full of DevSecOps Best Practices
  • Front-End: Cache Strategies You Should Know
  • Payments Architecture - An Introduction
  • Using Render Log Streams to Log to Papertrail

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: