[ANN] libgmail 0.0.3 -- Gmail access via Python
follower at gmail.com
Tue Jul 13 00:22:57 CEST 2004
David Fraser <davidf at sjsoft.com> wrote in message
> This is getting really cool. One suggestion: the example on the home
> page needs a libgmail in front of the GmailAccount constructor
Thanks for the positive feedback, David. And for revealing me as a
developer who doesn't check the sample code he puts up on his web
site. :-) I appreciate you taking the time to do so and have now fixed
> I couldn't work out how to get the gmail.js required to update the
> constants.py. Maybe being able to give username and password to
Thanks for the suggestion, I have added a function
Unfortunately with the last code update Gmail stopped including the
constant definitions so 'mkconstants.py' isn't much use with the
lucky enough to have a sav^h^h^h cached copy of a previous version...)
Of course, I understand why they did it, it knocked ~30K from the
download so it's now "only" ~230K--many of the constant names were
longer than the associated values.
The above change is only in CVS at the moment, the next release will
BTW, the latest CVS version *also* includes a SMTP server which allows
you to send messages via Gmail with any standard mail client. Python's
(until recently) undocumented `smtpd.py` SMTP server framework made
this an incredibly easy addition, although I extended it to handle
basic EHLO & AUTH user authentication commands.
Thanks again for your feedback.
P.S. Apologies for the delay in replying, Google Groups seems to be
delaying c.l.p the last few days.
P.P.S. Here is a (semi-edited, so probably won't run :-)) chunk of
code for extending the SMTP server to ESMTP for posterity, if I don't
get around to reworking it as a patch for `smtpd.py` (it's pretty
rough, no real error checking etc...).
--- Code follows --->
def process_message(self, peer, mailfrom, rcpttos, data):
# Need to process message here by subclassing...
conn, addr = self.accept()
print >> smtpd.DEBUGSTREAM, \
'Incoming connection from %s' % repr(addr)
channel = ESMTPChannel(self, conn, addr)
def smtp_EHLO(self, arg):
if not arg:
self.push('501 Syntax: EHLO hostname')
self.push('503 Duplicate HELO/EHLO')
self._SMTPChannel__greeting = arg
self.push('250-%s' % self._SMTPChannel__fqdn)
self.push('250 AUTH LOGIN PLAIN')
def smtp_AUTH(self, arg):
kind, data = arg.split(" ")
# TODO: Ensure kind == "PLAIN"
data = base64.decodestring(data)[1:]
user, pw = data.split("\x00")
# Try to log in here...
self.push("535 Authorization failed")
if __name__ == "__main__":
#smtpd.DEBUGSTREAM = sys.stderr
server = ESMTPProxy(("localhost", 8025), None)
More information about the Python-list