擅长:python、mysql、java
<p>是的,SMTPD模块将帮助完成。
<a href="http://pymotw.com/2/smtpd/" rel="noreferrer">Example code is here</a>:</p>
<blockquote>
<pre><code>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()
</code></pre>
</blockquote>