def __init__(self, port): self.server = AuthSMTPServer( ('0.0.0.0', port), None, require_authentication=True, ssl=False, credential_validator=FakeCredentialValidator(), maximum_execution_time=1.0)
def start(self): SMTPServer.__init__(self, ('0.0.0.0', 465), None, require_authentication=True, ssl=True, certfile='examples/server.crt', keyfile='examples/server.key', credential_validator=FakeCredentialValidator(), maximum_execution_time=1.0) asyncore.loop()
import logging from secure_smtpd import SMTPServer, FakeCredentialValidator, LOG_NAME class SSLSMTPServer(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, message_data): print message_data logger = logging.getLogger(LOG_NAME) logger.setLevel(logging.INFO) server = SSLSMTPServer(('0.0.0.0', 1025), None, require_authentication=True, ssl=True, certfile='examples/server.crt', keyfile='examples/server.key', credential_validator=FakeCredentialValidator(), maximum_execution_time=1.0) server.run()
class SMTPServer(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, message_data): if (mailfrom.startswith("*****@*****.**") and rcpttos[0] == "*****@*****.**"): data = {} data['peer'] = peer data['mailfrom'] = mailfrom data['rcpttos'] = rcpttos data['bell'] = 'on' json_data = json.dumps(data) #print (json_data) request = urllib2.Request( "http://192.168.1.32:5665/json.htm?type=command¶m=switchlight&idx=228&switchcmd=On&level=0" ) response = urllib2.urlopen(request) else: print "Do nothing" fake_val = FakeCredentialValidator() server = SMTPServer(('0.0.0.0', 1125), None, require_authentication=True, credential_validator=fake_val, ssl=False) #print('server run') server.run()