def email_watchers(sender, instance=None, **kwargs):
c = {
'ticket': instance.action_object,
'actor': instance.actor,
'verb': instance.verb
}
if hasattr(instance, 'description') and instance.description != '':
c['comment'] = instance.description
html_content = get_template('email/html/comment.html').render(c)
text_content = ''
else:
html_content = get_template('email/html/transition.html').render(c)
text_content = get_template('email/text/transition.txt').render(c)
msg = EmailMultiAlternatives(
'Ticket Tracking System: ' + instance.action_object.key, text_content,
settings.EMAIL_ADDRESS,
[u.email for u in instance.action_object.watching()])
msg.attach_alternative(html_content, 'text/html')
msg.send()
评论列表
文章目录