Edgewall Software

Changes between Version 3 and Version 4 of TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.IEmailDecorator


Ignore:
Timestamp:
Mar 12, 2017, 10:11:03 AM (7 years ago)
Author:
Peter Suter
Comment:

Move additional examples to wiki:CookBook/Notification/Email

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.IEmailDecorator

    v3 v4  
    4040}}}
    4141
    42 === !ReplyToTicketDecorator
    43 
    44 Another example (adapted from [th:comment:4:ticket:10044 a feature request]) changes the reply-to address depending on the ticket id (so recipients can just reply to the emails and e.g. th:EmailtoTracScript can forward such replies to `10044@trac-hacks.org` to [th:ticket:10044 the appropriate ticket]):
    45 {{{#!python
    46 from trac.core import Component, implements
    47 from trac.config import Option
    48 from trac.notification.api import IEmailDecorator
    49 from trac.notification.mail import set_header
    50 
    51 class ReplyToTicketDecorator(Component):
    52     """Replaces the 'Reply-To' header for tickets with a dynamic email address.
    53 
    54     Uses a new config option 'ticket_smtp_replyto'.
    55     """
    56     implements(IEmailDecorator)
    57 
    58     ticket_smtp_replyto = Option('notification', 'ticket_smtp_replyto', '__id__@localhost',
    59                 """Reply-To address for ticket notification emails.
    60 
    61                    ` __id__` is replaced with the ticket id.""")
    62 
    63     def decorate_message(self, event, message, charset):
    64         if event.realm == 'ticket':
    65             replyto = self.ticket_email_replyto.replace('__id__', str(event.target.id))
    66             set_header(message, 'Reply-To', replyto, charset)
    67 }}}
    68 
    69 === !AttachmentEmailDecorator
    70 See comment:9:ticket:3054
     42See wiki:CookBook/Notification/Email for more examples.
    7143
    7244== Available Implementations ==