⬆️ ⬇️

A bunch of GMail + Python + Django

There is a nice library for Python - libGmail . Using this library is very easy to receive and send letters with GMail. And 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 my hoster’s built-in SMTP server. Plus, the lack of spam in the service mailbox :) All spam gets into GMail.



Cross post from my blog .

Source: https://habr.com/ru/post/20994/



All Articles