Beispiel #1
0
 def __init__(self, localaddr, remoteaddr):
     self.server = smtpd.PureProxy(localaddr, remoteaddr)
     self.thread_id = thread.start_new_thread(asyncore.loop, ())
Beispiel #2
0
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2008 Doug Hellmann All rights reserved.
#
"""
"""

__version__ = "$Id$"
#end_pymotw_header

import smtpd
import asyncore

server = smtpd.PureProxy(('127.0.0.1', 1025), ('mail', 25))

asyncore.loop()
Beispiel #3
0
#! /usr/bin/env/python
# -*- coding:utf-8 -*-

import smtpd
import asyncore

server = smtpd.PureProxy(('127.0.0.1',1025),('smtp.163.com',25))
asyncore.loop()
Beispiel #4
0
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(('192.168.10.49', 1025), ('mail', 25), decode_data=True)
server = smtpd.PureProxy(('192.168.10.49', 1025), ('mail', 25), decode_data=True)

asyncore.loop()
Beispiel #5
0
        server = CustomSMTPServer(("192.168.1.150", 1025), None)

        # SMTPServer requires asyncore, so to run the server we cal; asyncore.loop()
        asyncore.loop()

    if results.section == 2:
        logger = logging.getLogger("13.2.2 Debugging Server")
        # The previous example shows the arguments to process_message(), but smtpd also includes a server specifically
        # designed for more complete debugging, called DebuggingServer.  It prints the entrie incoming message to the
        # console, then stops processing (it doesn't proxy the message to a real mail server)
        server = smtpd.DebuggingServer(("192.168.1.150", 1025), None)
        asyncore.loop()

    if results.section == 3:
        logger = logging.getLogger("13.2.3 Proxy Server")
        # The PureProxy class implements a straightforward proxy server.  incoming messages are forwarded upstream to
        # the server given as an argument to the constructor.
        # WARNING: Running this has a good chance to make you into an open relay.
        server = smtpd.PureProxy(("192.168.1.150", 1025),
                                 ('192.168.1.160', 1025))
        asyncore.loop()

else:
    # If the command isn't recognized because it wasn't given, show the help.
    if not results.section:
        parser.parse_args(['-h'])
    else:
        # If the command isn't recognized because it"s wrong, show an error.
        logger = logging.getLogger("ERROR")
        logger.warning("Command not recognized: %s", results.section)