Hello,

I was experiencing a notification email sending failure on debian lenny
stable, using python 2.5.2 and Trac 0.11.6 release(Trac-0.11.6-py2.5.egg),
the smtp server was a Zmail 0.6.

The trac log:
{{{
2009-12-02 18:06:54,899 Trac[web_ui] ERROR: Failure sending notification on
change to ticket #942: SMTPAuthenticationError: (504, 'AUTH mechanism')
}}}

The smtp session underneath was something like:
{{{
220 ESMTP ZMail V0.6
EHLO blablabla
250-AUTH LOGIN
250 AUTH=LOGIN
AUTH LOGIN base64_username
504 AUTH mechanism
}}}

Looks like Zmail 0.6 was not expecting a "AUTH LOGIN base64_username"
command, which was sent by python's smtplib.login() method. However, it
accepted:
{{{
220 ESMTP ZMail V0.6
EHLO blablabla
250-AUTH LOGIN
250 AUTH=LOGIN
AUTH LOGIN
334 VXNlcm5hbWU6
base64_username
334 UGFzc3dvcmQ6
base64_password
235 Authentication successful
}}}

Note: gmail is smart enough to accept both..

So, I did some hack into notification.py to make it work, wish it is of some
help for Zmail 0.6 victims and like. The solution is catching the raised
exception and retrying with AUTH LOGIN only.

{{{
#!diff
--- notification.py.orig        2009-12-02 22:49:08.000000000 +0800
+++ notification.py     2009-12-03 13:16:38.000000000 +0800
@@ -320,8 +320,24 @@
             self.server.starttls()
             self.server.ehlo()
         if self.user_name:
-            self.server.login(self.user_name.encode('utf-8'),
+            from smtplib import SMTPAuthenticationError
+            try:
+                self.server.login(self.user_name.encode('utf-8'),
                               self.password.encode('utf-8'))
+            except SMTPAuthenticationError:
+                # hack for Zmail 0.6
+                import string
+                if string.find(self.server.ehlo_resp, "AUTH LOGIN\n") == 0
:
+                    import base64
+                    code,resp = self.server.docmd('AUTH', 'login')
+                    if code != 334 :
+                        raise SMTPAuthenticationError(code, resp)
+                    code,resp =
self.server.docmd(base64.b64encode(self.user_name.encode('utf-8')))
+                    if code != 334 :
+                        raise SMTPAuthenticationError(code, resp)
+                    code,resp =
self.server.docmd(base64.b64encode(self.password.encode('utf-8')))
+                    if code != 235 :
+                        raise SMTPAuthenticationError(code, resp)
}}}


Cheers,
Kaiwang

--

You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.


Reply via email to