Creating Python Email (receiving) server

后端 未结 2 1624
生来不讨喜
生来不讨喜 2021-02-06 00:40

I am trying to produce a simple python script for a Linux VPS that will allow me to receive mail, (and then I can do stuff to it in python, like print it to stdout). Nothing mor

相关标签:
2条回答
  • 2021-02-06 01:28

    Pythons smtpd is sufficient.

    You might also want to take a look at inbox.py and this example

    0 讨论(0)
  • 2021-02-06 01:38

    Yes SMTPD Module will be help full. Example code is here:

    import smtpd
    import asyncore
    
    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()
    
    0 讨论(0)
提交回复
热议问题