[ANN] libgmail 0.0.3 -- Gmail access via Python

Discussion in 'Python' started by Follower, Jul 7, 2004.

  1. Follower

    Follower Guest

    libgmail -- Python binding for Google's Gmail service

    <http://libgmail.sf.net/>

    The `libgmail` project is a pure Python binding to provide access to
    Google's Gmail web-mail service.

    The library currently ships with one demonstration utility to archive
    messages from a Gmail account into mbox files, suitable for importing
    into a local email client.

    License: GPL 2.0

    Major changes since 0.0.1 & 0.0.2:

    * Archive Gmail to mbox utility.

    * No longer requires external ClientCookie package.

    * Uses constants extracted directly from Gmail Javascript,
    and includes utility to repeat the process if required.

    * Code & API refactoring.

    * Lazy retrieval and caching of thread and message data.

    * Sourceforge project & home page.


    <p><a href="http://libgmail.sf.net/">libgmail 0.0.3</a> - The
    `libgmail` project is a pure Python binding to provide access to
    Google's Gmail web-mail service. (08-Jul-04)</p>
    Follower, Jul 7, 2004
    #1
    1. Advertising

  2. Follower

    David Fraser Guest

    Follower wrote:
    > libgmail -- Python binding for Google's Gmail service
    >
    > <http://libgmail.sf.net/>
    >
    > The `libgmail` project is a pure Python binding to provide access to
    > Google's Gmail web-mail service.
    >
    > The library currently ships with one demonstration utility to archive
    > messages from a Gmail account into mbox files, suitable for importing
    > into a local email client.
    >
    > License: GPL 2.0
    >
    > Major changes since 0.0.1 & 0.0.2:
    >
    > * Archive Gmail to mbox utility.
    >
    > * No longer requires external ClientCookie package.
    >
    > * Uses constants extracted directly from Gmail Javascript,
    > and includes utility to repeat the process if required.
    >
    > * Code & API refactoring.
    >
    > * Lazy retrieval and caching of thread and message data.
    >
    > * Sourceforge project & home page.
    >
    >
    > <p><a href="http://libgmail.sf.net/">libgmail 0.0.3</a> - The
    > `libgmail` project is a pure Python binding to provide access to
    > Google's Gmail web-mail service. (08-Jul-04)</p>



    This is getting really cool. One suggestion: the example on the home
    page needs a libgmail in front of the GmailAccount constructor

    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
    mkconstants to let it fetch the javascript would be a good idea?

    Cheers
    David
    David Fraser, Jul 8, 2004
    #2
    1. Advertising

  3. Follower

    David Fraser Guest

    Follower wrote:
    > libgmail -- Python binding for Google's Gmail service
    >
    > <http://libgmail.sf.net/>
    >
    > The `libgmail` project is a pure Python binding to provide access to
    > Google's Gmail web-mail service.
    >
    > The library currently ships with one demonstration utility to archive
    > messages from a Gmail account into mbox files, suitable for importing
    > into a local email client.
    >
    > License: GPL 2.0
    >
    > Major changes since 0.0.1 & 0.0.2:
    >
    > * Archive Gmail to mbox utility.
    >
    > * No longer requires external ClientCookie package.
    >
    > * Uses constants extracted directly from Gmail Javascript,
    > and includes utility to repeat the process if required.
    >
    > * Code & API refactoring.
    >
    > * Lazy retrieval and caching of thread and message data.
    >
    > * Sourceforge project & home page.
    >
    >
    > <p><a href="http://libgmail.sf.net/">libgmail 0.0.3</a> - The
    > `libgmail` project is a pure Python binding to provide access to
    > Google's Gmail web-mail service. (08-Jul-04)</p>



    This is getting really cool. One suggestion: the example on the home
    page needs a libgmail in front of the GmailAccount constructor

    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
    mkconstants to let it fetch the javascript would be a good idea?

    Cheers
    David
    David Fraser, Jul 8, 2004
    #3
  4. Follower

    Follower Guest

    David Fraser <> 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
    the page.

    > 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
    > mkconstants to let it fetch the javascript would be a good idea?

    Thanks for the suggestion, I have added a function
    '_retrieveJavascript' to 'GmailAccount' to assist in doing that.
    Unfortunately with the last code update Gmail stopped including the
    constant definitions so 'mkconstants.py' isn't much use with the
    current Javascript. (*Fortunately* my, um, "friend" might have been
    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
    include it.

    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.

    --Phil.

    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 --->

    import base64
    import asyncore

    import smtpd


    class ESMTPProxy(smtpd.SMTPServer):
    """
    """

    def process_message(self, peer, mailfrom, rcpttos, data):
    """
    """
    # Need to process message here by subclassing...


    def handle_accept(self):
    conn, addr = self.accept()
    print >> smtpd.DEBUGSTREAM, \
    'Incoming connection from %s' % repr(addr)
    channel = ESMTPChannel(self, conn, addr)


    class ESMTPChannel(smtpd.SMTPChannel):
    """
    """

    def smtp_EHLO(self, arg):
    if not arg:
    self.push('501 Syntax: EHLO hostname')
    return
    if self._SMTPChannel__greeting:
    self.push('503 Duplicate HELO/EHLO')
    else:
    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:
    # Try to log in here...
    except:
    self.push("535 Authorization failed")
    else:
    self.push('235 Ok')


    if __name__ == "__main__":

    #smtpd.DEBUGSTREAM = sys.stderr

    server = ESMTPProxy(("localhost", 8025), None)

    asyncore.loop()
    Follower, Jul 12, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Follower
    Replies:
    10
    Views:
    686
    Fazer
    Aug 16, 2004
  2. Follower
    Replies:
    0
    Views:
    279
    Follower
    Jul 11, 2004
  3. Follower
    Replies:
    2
    Views:
    812
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Aug 4, 2004
  4. Follower
    Replies:
    0
    Views:
    497
    Follower
    Aug 22, 2004
  5. Andrea Gavana
    Replies:
    1
    Views:
    3,075
    litrush
    Aug 11, 2011
Loading...

Share This Page