a plugin for mail notifications

A plugin was implemented to send mail notifications when a player is invited or when a game is completed. The plugins implemented was modified to help the mail plugin implementation.

sending mails

The user name is usually an email address. This is enforced by the validation of the input field of the home page that refuses to accept a string that is not an email. The emails have been designed to be sent on every game event. It was implemented for a subset only:

ALLOWED = ( 'pick', 'vote', 'complete', 'invite' )

At initialization, the plugin loads templates from –plugins-dir and stores them in core:

        self.templates = {}
        for allowed in self.ALLOWED:
            f = open(os.path.join(dir, 'templates', allowed, 'template.html'))
            self.templates[allowed] = f.read()

It also loads configuration parameters from –plugins-confdir using lxml:

self.confdir = os.path.join(self.service.settings['plugins-confdir'], 'mail')
self.settings = objectify.parse(open(os.path.join(self.confdir, 'mail.xml'))).getroot()
self.sender = self.settings.get('sender')
self.host = self.settings.get('host')
self.url = self.settings.get('url')

When the plugin is notified of an event for which there is a mail to be sent, it
replaces variables from the template with values from the game:


will be replaced with


For the complete and invite states the following variables are replaced:


and for the vote and picked states the following variables are replaced:


The email being sent triggers spam errors, mostly because they are all HTML and contains external images.