首先在trac.ini文件中配置一下mail选项和日志选项。使日志文件记录可以开启。通过查看日志。看到以下问题
raceback (most recent call last):
File "C:\Python24\Lib\site-packages\trac\ticket\web_ui.py", line 562, in _do_save
tn.notify(ticket, newticket=False, modtime=now)
File "C:\Python24\Lib\site-packages\trac\ticket\notification.py", line 129, in notify
NotifyEmail.notify(self, ticket.id, subject)
File "C:\Python24\Lib\site-packages\trac\notification.py", line 216, in notify
Notify.notify(self, resid)
File "C:\Python24\Lib\site-packages\trac\notification.py", line 114, in notify
self.begin_send()
File "C:\Python24\Lib\site-packages\trac\notification.py", line 287, in begin_send
self.server.login(self.user_name, self.password)
File "C:\Python24\lib\smtplib.py", line 591, in login
raise SMTPAuthenticationError(code, resp)
SMTPAuthenticationError: (334, 'UGFzc3dvcmQ6')
raceback (most recent call last):
File "C:\Python24\Lib\site-packages\trac\ticket\web_ui.py", line 562, in _do_save
tn.notify(ticket, newticket=False, modtime=now)
File "C:\Python24\Lib\site-packages\trac\ticket\notification.py", line 129, in notify
NotifyEmail.notify(self, ticket.id, subject)
File "C:\Python24\Lib\site-packages\trac\notification.py", line 216, in notify
Notify.notify(self, resid)
File "C:\Python24\Lib\site-packages\trac\notification.py", line 114, in notify
self.begin_send()
File "C:\Python24\Lib\site-packages\trac\notification.py", line 287, in begin_send
self.server.login(self.user_name, self.password)
File "C:\Python24\lib\smtplib.py", line 591, in login
raise SMTPAuthenticationError(code, resp)
SMTPAuthenticationError: (334, 'UGFzc3dvcmQ6')
其他的提示也差不多是这一种了
其实上述只是提供了一个程序调用的过程。在调用smtplib。py这个模块的时候出了问题
通过抓包显示(EHLO WINEYWFBF1TTDV 250-AUTH=LOGIN 250 AUTH LOGIN)。邮件服务器返回的是 auth=LOGIN,多了一个'=',所以我就在smtplib.py文件中的第569行加了这一段
if '='+method in authlist:
authmethod = method
break
以下程序(580行以下)
elif authmethod == AUTH_LOGIN:
(code, resp) = self.docmd("AUTH",
"%s %s" % (AUTH_LOGIN, encode_base64(user, eol="")))
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(password, eol=""))
elif authmethod is None:
raise SMTPException("No suitable authentication method found.")
if code not in [235, 503]:
其实上述只是提供了一个程序调用的过程。在调用smtplib。py这个模块的时候出了问题
通过抓包显示(EHLO WINEYWFBF1TTDV 250-AUTH=LOGIN 250 AUTH LOGIN)。邮件服务器返回的是 auth=LOGIN,多了一个'=',所以我就在smtplib.py文件中的第569行加了这一段
if '='+method in authlist:
authmethod = method
break
以下程序(580行以下)
elif authmethod == AUTH_LOGIN:
(code, resp) = self.docmd("AUTH",
"%s %s" % (AUTH_LOGIN, encode_base64(user, eol="")))
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(password, eol=""))
elif authmethod is None:
raise SMTPException("No suitable authentication method found.")
if code not in [235, 503]:
修改为
elif authmethod == AUTH_LOGIN:
# Three stage: 1. sent "AUTH LOGIN"; 2. sent "user name"; 3. sent "password".
# origial code combine stage 1 & 2 as below line:
#(code, resp) = self.docmd("AUTH","%s %s" % (AUTH_LOGIN, encode_base64(user, eol="")))
# Three stage: 1. sent "AUTH LOGIN"; 2. sent "user name"; 3. sent "password".
# origial code combine stage 1 & 2 as below line:
#(code, resp) = self.docmd("AUTH","%s %s" % (AUTH_LOGIN, encode_base64(user, eol="")))
(code, resp) = self.docmd("AUTH", AUTH_LOGIN)
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(user, eol=""))
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(password, eol=""))
elif authmethod is None:
raise SMTPException("No suitable authentication method found.")
if code not in [235, 503]:
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(user, eol=""))
if code != 334:
raise SMTPAuthenticationError(code, resp)
(code, resp) = self.docmd(encode_base64(password, eol=""))
elif authmethod is None:
raise SMTPException("No suitable authentication method found.")
if code not in [235, 503]:
保存后就肯定可以发邮件了啊。不知道最新版本是否解决了这个问题。大家可以测试一下啊!
转载于:https://blog.51cto.com/dadekey/60350