| 46 | |
| 47 | == Reply-To Ticket Owner |
| 48 | Some projects want to replies to ticket email notifications to be directly sent to the ticket owner's email address. |
| 49 | |
| 50 | 1. 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 | |
| 65 | from trac.core import Component, implements |
| 66 | from trac.notification.api import IEmailDecorator |
| 67 | from trac.notification.mail import RecipientMatcher, set_header |
| 68 | |
| 69 | class 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 | ---- |
| 88 | See also: #6789, #10578 |