Third party highly customizable email marketing infrastructure is quiet costly compared to owning dedicate email server. Companies providing low cost email marketing packages has limitation on daily/monthly mail count and bandwidth. Even there is no guaranty of any hosted mailing server, If internet users mark sent mail/IP as spam, server get black listed. So It’s wise to use trusted mailing infrastructure in budget cost.
Google App Engine allows daily 2000 mail resource usage for free. For more quota one can easily upgrade membership and have reliable and trustful emailing infrastructure.
Features
- Django template based mailer
- IP address validation/filtering.
- Generating PHP API on the fly for remote requests.
- Task Queue based mail sending module.
Summary of Application
- First of all it ask for admin’s google account credentials whenever we point browser to http://appid.appspot.com
- After successful login, It shows dashboard containing existing created mailer templates.

- Admin can add, edit, delete templates. It also allows python django template variables. i.e. Dear {{username}}

- To get Google App Engine request curl api address, one need to go inside edit mailer.

- It also allows admin to configure our app for limited IP addresses.

Here is a demo code for Google App Engine Mail task queue
app.yaml
application: your_app version: 1 runtime: python api_version: 1 handlers: - url: /picknsend* script: picknsend.py
queue.yaml
queue: - name: limitedemail rate: 2000/d
Setting up task queue
try:
from google.appengine.api.labs import taskqueue
except ImportError:
from google.appengine.api import taskqueue # for official inclusion of taskqueue.
# schedule task queue for sending mail
q = taskqueue.Queue('limitedemail')
t = taskqueue.Task(url='/picknsend', method='POST')
q.add(t)
picknsend.py
#!/usr/bin/env python
# /picknsend task queue job
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
from google.appengine.api import mail
class MailQueue(db.Model):
mail_to = db.StringProperty(required=True)
mail_subject = db.StringProperty(required=True)
mail_body = db.TextProperty(required=True)
mail_datetime = db.DateTimeProperty(auto_now_add=True)
mail_sent = db.BooleanProperty(default=False)
class PickAndSendMail(webapp.RequestHandler):
def post(self):
self.sendmail()
def sendmail(self):
m = MailQueue.gql("WHERE mail_sent=False ORDER BY mail_datetime asc").fetch(1)
for i in m:
BODY = i.mail_body
TO = i.mail_to
SUBJECT = i.mail_subject
mail.send_mail('your_email@gmail.com',TO,SUBJECT,BODY)
for i in m:
i.mail_sent = True # marking... mail gone
i.put()
def main():
application = webapp.WSGIApplication([('/picknsend*', PickAndSendMail)], debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Above code is not our entire application. It’s just one of the sample module that Google App Engine developer can refer for development.

Recent Comments