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:

href='%(url)s/?game_id=%(game_id)d'

will be replaced with

href='%(url)s/?game_id=204'

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

url=%(url)s
game_id=%(game_id)d
owner_email=%(owner_email)s

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

url=%(url)s
game_id=%(game_id)d
player_email=%(player_email)s

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

This entry was posted in cardstories. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>