A bunch of GMail + Python + Django

    There is a nice library for Python - libGmail . Using this library it is very simple to receive and send letters with GMail. You can also make a POP or SMTP server from your account.

    LibGmail can be used both with Python and in conjunction with any popular framework. For example, with Django .

    For example, I use the following code to send a notification about the need to activate an account to a new user:

    import libgmail
    ...

    def activation (request):
        to_email = request.user.email
        activation_link = dontbeevil.com/activate/%s% request.COOKIES ["sessionid"]
        ga = libgmail.GmailAccount (dontbeevil@gmail.com, "ourpassword" )
        ga.login ()
        subject = "Service Administration"
        msg = "Dear user! To activate your account, use this link:% s ยป% activation_link
        gmsg = libgmail.GmailComposedMessage (to_email, subject, msg)
        ga.sendMessage (gmsg)
    ...


    Using LibGmail saved me from having to use the built-in SMTP server of my hoster. Plus, the absence of spam to the office mailbox :) All spam goes to GMail.

    Cross-post from my blog .

    Also popular now: