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