Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
+0
Start Page
Index
History
Editing CookBook/Notification/Email
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
= Notification Customizations [[PageOutline(2)]] TracNotification customizations can often be implemented with a short plugin. Some custom examples are given on this page. == Attachments in Notification Emails This email decorator can be used to send new ticket attachments as email attachments with the notification emails. Create a [TracDev/PluginDevelopment#Singlefileplugins single file plugin] that implements [wiki:TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.IEmailDecorator IEmailDecorator]: {{{#!python # -*- coding: utf-8 -*- # # Copyright (C) 2017 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://trac.edgewall.org/wiki/TracLicense. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://trac.edgewall.org/log/. from email.mime.application import MIMEApplication from trac.core import Component, implements from trac.notification.api import IEmailDecorator class AttachmentEmailDecorator(Component): implements(IEmailDecorator) # IEmailDecorator methods def decorate_message(self, event, message, charset): if event.category == 'attachment added': attachment = event.attachment filename = attachment.filename with attachment.open() as fd: part = MIMEApplication(fd.read(), Name=filename) part['Content-Disposition'] = 'attachment; filename="%s"' % filename message.attach(part) }}} See also: #3054 == Reply-To Ticket Notification Emails th:EmailtoTracScript and a small plugin to change the Reply-To address allow users to reply directly to notification emails to append comments to a ticket. The Reply-To header is changed depending on the ticket id so replies are sent to for example `10044@trac-hacks.org` and can be appended to ticket [th:ticket:10044 #10044]: 1. Create a [TracDev/PluginDevelopment#Singlefileplugins single file plugin] that implements [wiki:TracDev/PluginDevelopment/ExtensionPoints/trac.notification.api.IEmailDecorator IEmailDecorator]: {{{#!python # -*- coding: utf-8 -*- # # Copyright (C) 2017 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://trac.edgewall.org/wiki/TracLicense. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://trac.edgewall.org/log/. from trac.core import Component, implements from trac.config import Option from trac.notification.api import IEmailDecorator from trac.notification.mail import set_header class ReplyToTicketDecorator(Component): """Replaces the 'Reply-To' header for tickets with a dynamic email address. Uses a new config option 'ticket_smtp_replyto'. """ implements(IEmailDecorator) ticket_smtp_replyto = Option('notification', 'ticket_smtp_replyto', '__id__@localhost', """Reply-To address for ticket notification emails. ` __id__` is replaced with the ticket id.""") def decorate_message(self, event, message, charset): if event.realm == 'ticket': replyto = self.ticket_email_replyto.replace('__id__', str(event.target.id)) set_header(message, 'Reply-To', replyto, charset) }}} See also: th:EmailtoTracScript, th:comment:4:ticket:10044
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.