Python/smtpd

smtpd
smtpd – Sample SMTP Servers - Python Module of the Week - https://pymotw.com/2/smtpd/

Server: import smtpd import asyncore
 * 1) smtpd-server.py

class CustomSMTPServer(smtpd.SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): print 'Receiving message from:', peer print 'Message addressed from:', mailfrom print 'Message addressed to :', rcpttos print 'Message length       :', len(data) return

server = CustomSMTPServer(('127.0.0.1', 1025), None)

asyncore.loop

Client: import smtplib import email.utils from email.mime.text import MIMEText
 * 1) smtpd-client.py

msg = MIMEText('This is the body of the message.') msg['To'] = email.utils.formataddr(('Recipient', 'recipient@example.com')) msg['From'] = email.utils.formataddr(('Author', 'author@example.com')) msg['Subject'] = 'Simple test message'
 * 1) Create the message

server = smtplib.SMTP('127.0.0.1', 1025) server.set_debuglevel(True) # show communication with the server try: server.sendmail('author@example.com', ['recipient@example.com'], msg.as_string) finally: server.quit

This worked on Windows, and was a great way to trick Outlook into thinking there was a SMTP server for an inbound only account.