Changes between Version 1 and Version 2 of Ticket #10044, comment 4


Ignore:
Timestamp:
Oct 17, 2013, 5:54:02 AM (5 years ago)
Author:
Peter Suter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10044, comment 4

    v1 v2  
    11I have not tested this, but I think it should be possible to implement something useful using a `IAnnouncementEmailDecorator`. For example something like:
    22{{{#!python
     3from email.utils import parseaddr, formataddr
     4
     5from trac.core import Component, implements
     6
     7from announcer.distributors.mail import IAnnouncementEmailDecorator
     8from announcer.util.mail import next_decorator, set_header
     9
    310class FromTicketDecorator(Component):
    411    """Replaces the 'From' header for ticket events with a dynamic email address.
     
    1825        if event.realm == 'ticket':
    1926            from_header = formataddr(
    20                     (self.from_name and self.from_name or self.env.project_name,
    21                      self.ticket_email_from.replace('__id__', str(event.target['id']))
     27                     (parseaddr(message['From'])[0],
     28                      self.ticket_email_from.replace('__id__', str(event.target['id']))))
    2229            set_header(message, 'From', from_header)
    2330        return next_decorator(event, message, decorators)