#!/bin/env python import smtpd, smtplib, asyncore class GmailSMTPProxy(smtpd.SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): server = smtplib.SMTP('smtp.gmail.com',587) # server.set_debuglevel(1) server.ehlo() server.starttls() server.ehlo() server.login('user gmail com', 'password') server.sendmail(mailfrom, rcpttos, data) server.quit() if __name__ == '__main__': import __main__ GmailSMTPProxy(('localhost',8025), None) try: asyncore.loop() except KeyboardInterrupt: pass