<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://k2.ixota.com/index.php?action=history&amp;feed=atom&amp;title=Python%2Fsmtpd</id>
	<title>Python/smtpd - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://k2.ixota.com/index.php?action=history&amp;feed=atom&amp;title=Python%2Fsmtpd"/>
	<link rel="alternate" type="text/html" href="https://k2.ixota.com/index.php?title=Python/smtpd&amp;action=history"/>
	<updated>2026-06-26T11:01:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>https://k2.ixota.com/index.php?title=Python/smtpd&amp;diff=4436&amp;oldid=prev</id>
		<title>Kenneth: /* smtpd */</title>
		<link rel="alternate" type="text/html" href="https://k2.ixota.com/index.php?title=Python/smtpd&amp;diff=4436&amp;oldid=prev"/>
		<updated>2017-09-01T15:13:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;smtpd&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== smtpd ==&lt;br /&gt;
&lt;br /&gt;
smtpd – Sample SMTP Servers - Python Module of the Week - https://pymotw.com/2/smtpd/&lt;br /&gt;
&lt;br /&gt;
Server:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# smtpd-server.py&lt;br /&gt;
import smtpd&lt;br /&gt;
import asyncore&lt;br /&gt;
&lt;br /&gt;
class CustomSMTPServer(smtpd.SMTPServer):&lt;br /&gt;
    &lt;br /&gt;
    def process_message(self, peer, mailfrom, rcpttos, data):&lt;br /&gt;
        print &amp;#039;Receiving message from:&amp;#039;, peer&lt;br /&gt;
        print &amp;#039;Message addressed from:&amp;#039;, mailfrom&lt;br /&gt;
        print &amp;#039;Message addressed to  :&amp;#039;, rcpttos&lt;br /&gt;
        print &amp;#039;Message length        :&amp;#039;, len(data)&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
server = CustomSMTPServer((&amp;#039;127.0.0.1&amp;#039;, 1025), None)&lt;br /&gt;
&lt;br /&gt;
asyncore.loop()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Client:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# smtpd-client.py&lt;br /&gt;
import smtplib&lt;br /&gt;
import email.utils&lt;br /&gt;
from email.mime.text import MIMEText&lt;br /&gt;
&lt;br /&gt;
# Create the message&lt;br /&gt;
msg = MIMEText(&amp;#039;This is the body of the message.&amp;#039;)&lt;br /&gt;
msg[&amp;#039;To&amp;#039;] = email.utils.formataddr((&amp;#039;Recipient&amp;#039;, &amp;#039;recipient@example.com&amp;#039;))&lt;br /&gt;
msg[&amp;#039;From&amp;#039;] = email.utils.formataddr((&amp;#039;Author&amp;#039;, &amp;#039;author@example.com&amp;#039;))&lt;br /&gt;
msg[&amp;#039;Subject&amp;#039;] = &amp;#039;Simple test message&amp;#039;&lt;br /&gt;
&lt;br /&gt;
server = smtplib.SMTP(&amp;#039;127.0.0.1&amp;#039;, 1025)&lt;br /&gt;
server.set_debuglevel(True) # show communication with the server&lt;br /&gt;
try:&lt;br /&gt;
    server.sendmail(&amp;#039;author@example.com&amp;#039;, [&amp;#039;recipient@example.com&amp;#039;], msg.as_string())&lt;br /&gt;
finally:&lt;br /&gt;
    server.quit()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This worked on Windows, and was a great way to trick Outlook into thinking there was a SMTP server for an inbound only account.&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
		
	</entry>
</feed>