Smtpd server python
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
	
import asyncore
from smtpd import SMTPServer
class MySMTPServer(SMTPServer):
    def process_message(self, peer, mailfrom, rcpttos, data):
        print(f"Received message from: {mailfrom}")
        print(f"Recipients: {rcpttos}")
        print("Message:")
        print(data)
def run_server():
    # Replace 'localhost' and 1025 with the desired hostname and port
    server = MySMTPServer(('localhost', 1025), None)
    print("SMTP echo server running...")
    try:
        asyncore.loop()
    except KeyboardInterrupt:
        print("Server stopped.")
if __name__ == "__main__":
    run_server()