0

I need a python smtp server to receive multiple dvr alarm mail,store it and process. I looked around and found this simple code:

   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()

from the same machine it is ok, mail are received and read , from other pc in same LAN I cannot connect. What's wrong? Thanks all.

Calumah
  • 2,865
  • 1
  • 20
  • 30
  • Try start your server at your local ip address instead of 0.0.0.0. It should be sth like 192.168.0.123. – Frank Nov 08 '20 at 02:14
  • I have tried ip released from router (192.168.0.100 set as static/reserved) disabled all router firewall (it is a tp-link), enable all protocol and make my ip as DMZ, disabled windows(win7 x86) firewall but nothing changed. The sender machine cannot see the server. – francesco Nov 09 '20 at 14:13
  • It cloud be the port 1025 is closed. – Frank Nov 09 '20 at 16:41
  • Looking how to open port in win7 firewall i found this command "netsh advfirewall firewall add rule name = "Open port 1025 test" dir=in action=allow protocol=TCP localport=1025" on [link](https://serverfault.com/questions/883266/powershell-how-open-a-windows-firewall-port) . The rule is active but still cannot see server on lan. – francesco Nov 15 '20 at 22:55

0 Answers0