Many options, three that come into my mind right now are:
- use the Apps Script Gmail service, as shown in our Apps Script quickstart guide
- use App Engine as in the end-to-end example in the documentation
- connect to Gmail via SMTP to send emails from there