Python SMTP中的登录授权可能有什么问题?
所以我正在基于源代码开发自己的小型SMTP服务器。从IP摄像机接收消息。当我试图让用户名连接卡住时。这是我服务器上的日志。==客户Python SMTP中的登录授权可能有什么问题?,python,email,python-2.7,smtp,asyncore,Python,Email,Python 2.7,Smtp,Asyncore,所以我正在基于源代码开发自己的小型SMTP服务器。从IP摄像机接收消息。当我试图让用户名连接卡住时。这是我服务器上的日志。==客户 [2015-02-13 10:55:53] INFO: Server started at 192.168.0.103:1027 [2015-02-13 10:56:00] INFO: Incoming connection from ('**.***.****.****', 47178) [2015-02-13 10:56:00] DEBUG: <-- '2
[2015-02-13 10:55:53] INFO: Server started at 192.168.0.103:1027
[2015-02-13 10:56:00] INFO: Incoming connection from ('**.***.****.****', 47178)
[2015-02-13 10:56:00] DEBUG: <-- '220 ****** SMTP Server 0.1 ESMTP'
[2015-02-13 10:56:00] DEBUG: --> EHLO : 'localhost' # ECHLO localhost
[2015-02-13 10:56:00] DEBUG: <-- '250-****** SMTP Server 0.1 Hello localhost'
[2015-02-13 10:56:00] DEBUG: <-- '250-SIZE 20480000'
[2015-02-13 10:56:00] DEBUG: <-- '250 AUTH PLAIN'
[2015-02-13 10:56:00] DEBUG: --> AUTH : 'LOGIN' # AUTH LOGIN
[2015-02-13 10:56:00] DEBUG: <-- '334 VXNlcm5hbWU6'
我想也许《终结者》里有什么东西。。。通过设置\u终止符方法,我已尝试\n和\r\n。Auth方法如下所示:
def AUTH(self, arg):
logging.debug('--> AUTH : ' + repr(arg))
if 'PLAIN' in arg:
pass
elif 'LOGIN' in arg:
split_args = arg.split(' ')
if len(split_args) == 2:
self._username = base64.b64decode(split_args[1])
self.push('334 ' + str(base64.b64encode('Password:')))
else:
self.push('334 ' + str(base64.b64encode('Username:')))
elif not self._username:
self._username = base64.b64decode(arg)
self.push('334 ' + base64.b64encode('Password:'))
添加一些try块以进一步捕获异常。
def AUTH(self, arg):
logging.debug('--> AUTH : ' + repr(arg))
if 'PLAIN' in arg:
pass
elif 'LOGIN' in arg:
split_args = arg.split(' ')
if len(split_args) == 2:
self._username = base64.b64decode(split_args[1])
self.push('334 ' + str(base64.b64encode('Password:')))
else:
self.push('334 ' + str(base64.b64encode('Username:')))
elif not self._username:
self._username = base64.b64decode(arg)
self.push('334 ' + base64.b64encode('Password:'))