Edgewall Software

Changes between Version 3 and Version 4 of CookBook/Notification/Email


Ignore:
Timestamp:
Mar 12, 2017, 2:26:35 PM (7 years ago)
Author:
Peter Suter
Comment:

ReplyToTicketOwnerEmailDecorator

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/Notification/Email

    v3 v4  
    4444
    4545See also: #3054
     46
     47== Reply-To Ticket Owner
     48Some projects want to replies to ticket email notifications to be directly sent to the ticket owner's email address.
     49
     501. Create a [TracDev/PluginDevelopment#Singlefileplugins single file plugin] that implements [wiki:TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.IEmailDecorator IEmailDecorator]:
     51{{{#!python
     52# -*- coding: utf-8 -*-
     53#
     54# Copyright (C) 2017 Edgewall Software
     55# All rights reserved.
     56#
     57# This software is licensed as described in the file COPYING, which
     58# you should have received as part of this distribution. The terms
     59# are also available at http://trac.edgewall.org/wiki/TracLicense.
     60#
     61# This software consists of voluntary contributions made by many
     62# individuals. For the exact contribution history, see the revision
     63# history and logs, available at http://trac.edgewall.org/log/.
     64
     65from trac.core import Component, implements
     66from trac.notification.api import IEmailDecorator
     67from trac.notification.mail import RecipientMatcher, set_header
     68
     69class ReplyToTicketOwnerEmailDecorator(Component):
     70    """Use the ticket owner in the Reply-To header in notification emails."""
     71
     72    implements(IEmailDecorator)
     73
     74    def decorate_message(self, event, message, charset):
     75        if event.realm != 'ticket':
     76            return
     77        owner = event.target['owner']
     78        matcher = RecipientMatcher(self.env)
     79        owner = matcher.match_from_author(owner)
     80        if owner:
     81            set_header(message, 'Reply-To', owner, charset)
     82}}}
     83
     84==== Variations
     85* Reply to ticket ''updater'' by changing `event.target['owner']` to `event.author`.
     86
     87----
     88See also: #6789, #10578
    4689
    4790== Reply-To Ticket Notification Emails