import email.mime.text
import email.utils
import logging
+import random
import subprocess
import tornado.locale
import tornado.template
def make_recipient(self, recipient):
# Use the contact instead of the account
if isinstance(recipient, accounts.Account):
- recipient = "%s <%s>" % (recipient, recipient.email)
+ recipient = account.email_to
# Fall back to pass on strings
return recipient
"""
account = self.backend.accounts.get_by_mail(recipient)
+ posts = list(self.backend.blog.get_newest(limit=5))
+
kwargs = {
"account" : account,
"first_name" : account.first_name,
# Random activation/reset codes
"activation_code" : util.random_string(36),
"reset_code" : util.random_string(64),
+
+ # The latest blog post
+ "post" : random.choice(posts),
}
return self.send_template(template, recipients=[recipient,], **kwargs)