python - 如何将简单的 smtp python 服务器绑定到局域网?
问题描述
我需要一个 python smtp 服务器来接收多个 dvr 警报邮件,将其存储并处理。我环顾四周,发现了这个简单的代码:
from datetime import datetime
import asyncore
from smtpd import SMTPServer
class EmlServer(SMTPServer):
no = 0
def process_message(self,peer, mailfrom, rcpttos, data, **kwargs):
adesso=datetime.now().strftime('%Y%m%d%H%M%S')
print(adesso)
print(data)
return
filename=alarm.eml
with open(filename, 'w') as f:
f.write(data)
self.no += 1
return None
def run():
foo = EmlServer(('0.0.0.0', 1025), None,decode_data=True)
print(repr(foo))
try:
asyncore.loop()
except KeyboardInterrupt:
pass
except Exception as e:
print(repr(e))
if __name__ == '__main__':
run()
从同一台机器上没问题,可以接收和读取邮件,从同一局域网中的其他电脑我无法连接。怎么了?谢谢大家。
解决方案
推荐阅读
- android - 如何修复 FrameLayout 之间的空间 - ConstraintLayout
- java - Program type already present after updating from sdk 27 to 28
- html - 悬停在一种情况下有效,但在另一种情况下无效
- php - 持久完整性约束 Laravel
- c++ - Visual Studio 找不到 GL/glut.h
- c++ - OpenGL - 对象轮廓
- javascript - 如何在数据表中一次对两列进行排序
- python - tkinter 中主框架上的框架布局
- kotlin - 将每两个相等的元素合并为另一个
- sql - 如何在 SQL 表中正确使用 FK