Changes between Initial Version and Version 1 of TracNotification

Aug 21, 2017, 10:26:12 AM (6 years ago)



  • TracNotification

    v1 v1  
     1= Email Notification of Ticket Changes =
     4Trac supports notification of ticket changes via email.
     6Email notification is useful to keep users up-to-date on tickets/issues of interest, and also provides a convenient way to post all ticket changes to a dedicated mailing list. For example, this is how the [ Trac-tickets] mailing list is set up.
     8Disabled by default, notification can be activated and configured in [wiki:TracIni trac.ini].
     10== Receiving Notification Mails ==
     11When reporting a new ticket or adding a comment, enter a valid email address or your username in the ''reporter'', ''assigned to/owner'' or ''cc'' field. Trac will automatically send you an email when changes are made to the ticket (depending on how notification is configured).
     13This is useful to keep up-to-date on an issue or enhancement request that interests you.
     15=== How to use your username to receive notification mails ===
     17To receive notification mails, you can either enter a full email address or your username. To get notified with a simple username or login, you need to specify a valid email address in the ''Preferences'' page.
     19Alternatively, a default domain name ('''`smtp_default_domain`''') can be set in the TracIni file (see [#ConfigurationOptions Configuration Options] below). In this case, the default domain will be appended to the username, which can be useful for an "Intranet" kind of installation.
     21When using apache and mod_kerb for authentication against Kerberos / Active Directory, usernames take the form ('''`username@EXAMPLE.LOCAL`'''). To avoid this being interpreted as an email address, add the Kerberos domain to  ('''`ignore_domains`''').
     23== Configuring SMTP Notification ==
     25'''Important:''' For TracNotification to work correctly, the `[trac] base_url` option must be set in [wiki:TracIni trac.ini].
     27=== Configuration Options ===
     28These are the available options for the `[notification]` section in trac.ini.
     32=== Example Configuration (SMTP) ===
     35smtp_enabled = true
     36smtp_server =
     37smtp_from =
     38smtp_replyto =
     39smtp_always_cc =,
     42=== Example Configuration (`sendmail`) ===
     45smtp_enabled = true
     46email_sender = SendmailEmailSender
     47sendmail_path = /usr/sbin/sendmail
     48smtp_from =
     49smtp_replyto =
     50smtp_always_cc =,
     53=== Customizing the e-mail subject ===
     54The e-mail subject can be customized with the `ticket_subject_template` option, which contains a [ Genshi text template] snippet. The default value is:
     56$prefix #$ $summary
     58The following variables are available in the template:
     60 * `env`: The project environment (see [trac:source:/trunk/trac/]).
     61 * `prefix`: The prefix defined in `smtp_subject_prefix`.
     62 * `summary`: The ticket summary, with the old value if the summary was edited.
     63 * `ticket`: The ticket model object (see [trac:source:/trunk/trac/ticket/]). Individual ticket fields can be addressed by appending the field name separated by a dot, e.g. `$ticket.milestone`.
     65=== Customizing the e-mail content ===
     67The notification e-mail content is generated based on `ticket_notify_email.txt` in `trac/ticket/templates`.  You can add your own version of this template by adding a `ticket_notify_email.txt` to the templates directory of your environment. The default looks like this:
     72{% choose %}\
     73{%   when True %}\
     75{%   end %}\
     76{%   otherwise %}\
     77{%     if changes_body %}\
     78${_('Changes (by %(author)s):',}
     81{%     end %}\
     82{%     if changes_descr %}\
     83{%       if not changes_body and not change.comment and %}\
     84${_('Description changed by %(author)s:',}
     85{%       end %}\
     88{%     end %}\
     89{%     if change.comment %}\
     91${changes_body and _('Comment:') or _('Comment (by %(author)s):',}
     94{%     end %}\
     95{%   end %}\
     96{% end %}\
     99${_('Ticket URL: <%(link)s>',}
     100$ <${project.url or abs_href()}>
     103== Sample Email ==
     105#42: testing
     107       Id:  42             |      Status:  assigned               
     108Component:  report system  |    Modified:  Fri Apr  9 00:04:31 2004
     109 Severity:  major          |   Milestone:  0.9                     
     110 Priority:  lowest         |     Version:  0.6                     
     111    Owner:  anonymous      |    Reporter:               
     114  * component:  changset view => search system
     115  * priority:  low => highest
     116  * owner:  jonas => anonymous
     117  * cc: =>
     119  * status:  new => assigned
     122I'm interested too!
     125Ticket URL: <>
     126My Project <>
     130== Customizing e-mail content for MS Outlook ==
     132Out-of-the-box, MS Outlook normally presents plain text e-mails with a variable-width font; the ticket properties table will most certainly look like a mess in MS Outlook. This can be fixed with some customization of the [#Customizingthee-mailcontent e-mail template].
     134Replace the following second row in the template:
     139with this instead (''requires Python 2.6 or later''):
     142{% with
     143   pv = [(a[0].strip(), a[1].strip()) for a in [b.split(':') for b in
     144         [c.strip() for c in
     145          ticket_props.replace('|', '\n').splitlines()[1:-1]] if ':' in b]];
     146   sel = ['Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
     147          'Component', 'Severity', 'Resolution', 'Keywords'] %}\
     148${'\n'.join('%s\t%s' % (format(p[0]+':', ' <12'), p[1]) for p in pv if p[0] in sel)}
     149{% end %}\
     153The table of ticket properties is replaced with a list of a selection of the properties. A tab character separates the name and value in such a way that most people should find this more pleasing than the default table, when using MS Outlook.
     154{{{#!div style="margin: 1em 1.75em; border:1px dotted"
     156#42: testing<br />
     157--------------------------------------------------------------------------<br />
     158<table cellpadding=0>
     165<tr><td>Component:</td><td>report system</td></tr>
     167<tr><td>Resolution:</td><td> </td></tr>
     168<tr><td>Keywords:</td><td> </td></tr>
     170--------------------------------------------------------------------------<br />
     171Changes:<br />
     172<br />
     173&nbsp;&nbsp;* component: &nbsp;changset view =&gt; search system<br />
     174&nbsp;&nbsp;* priority: &nbsp;low =&gt; highest<br />
     175&nbsp;&nbsp;* owner: &nbsp;jonas =&gt; anonymous<br />
     176&nbsp;&nbsp;* cc: &nbsp; =&gt;<br />
     177&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,<br />
     178&nbsp;&nbsp;* status: &nbsp;new =&gt; assigned<br />
     179<br />
     180Comment:<br />
     181I'm interested too!<br />
     182<br />
     183--<br />
     184Ticket URL: &lt;;<br />
     185My Project &lt;;<br />
     189**Important**: Only those ticket fields that are listed in `sel` are part of the HTML mail. If you have defined custom ticket fields which shall be part of the mail they have to be added to `sel`, example:
     191   sel = ['Reporter', ..., 'Keywords', 'Custom1', 'Custom2']
     194However, it's not as perfect as an automatically HTML-formatted e-mail would be, but presented ticket properties are at least readable by default in MS Outlook...
     197== Using GMail as the SMTP relay host ==
     199Use the following configuration snippet
     202smtp_enabled = true
     203use_tls = true
     204mime_encoding = base64
     205smtp_server =
     206smtp_port = 587
     207smtp_user = user
     208smtp_password = password
     211where ''user'' and ''password'' match an existing GMail account, ''i.e.'' the ones you use to log in on []
     213Alternatively, you can use `smtp_port = 25`.[[br]]
     214You should not use `smtp_port = 465`. It will not work and your ticket submission may deadlock. Port 465 is reserved for the SMTPS protocol, which is not supported by Trac. See [trac:comment:2:ticket:7107 #7107] for details.
     216== Filtering notifications for one's own changes and comments ==
     217In Gmail, use the filter:
     220from:(<smtp_from>) (("Reporter: <username>" -Changes -Comment) OR "Changes (by <username>)" OR "Comment (by <username>)")
     223to delete these notifications.
     225In Thunderbird, there is no such solution if you use IMAP
     228You can also add this plugin:
     229, or vote for [trac:#2247] to be fixed.
     231== Troubleshooting ==
     233If you cannot get the notification working, first make sure the log is activated and have a look at the log to find if an error message has been logged. See TracLogging for help about the log feature.
     235Notification errors are not reported through the web interface, so the user who submit a change or a new ticket never gets notified about a notification failure. The Trac administrator needs to look at the log to find the error trace.
     237=== ''Permission denied'' error ===
     239Typical error message:
     241  ...
     242  File ".../", line 303, in connect
     243    raise socket.error, msg
     244  error: (13, 'Permission denied')
     247This error usually comes from a security settings on the server: many Linux distributions do not let the web server (Apache, ...) to post email message to the local SMTP server.
     249Many users get confused when their manual attempts to contact the SMTP server succeed:
     251telnet localhost 25
     253The trouble is that a regular user may connect to the SMTP server, but the web server cannot:
     255sudo -u www-data telnet localhost 25
     258In such a case, you need to configure your server so that the web server is authorized to post to the SMTP server. The actual settings depend on your Linux distribution and current security policy. You may find help browsing the Trac [trac:MailingList MailingList] archive.
     260Relevant ML threads:
     261 * SELinux:
     263For SELinux in Fedora 10:
     265$ setsebool -P httpd_can_sendmail 1
     267=== ''Suspected spam'' error ===
     269Some SMTP servers may reject the notification email sent by Trac.
     271The default Trac configuration uses Base64 encoding to send emails to the recipients. The whole body of the email is encoded, which sometimes trigger ''false positive'' SPAM detection on sensitive email servers. In such an event, it is recommended to change the default encoding to "quoted-printable" using the `mime_encoding` option.
     273Quoted printable encoding works better with languages that use one of the Latin charsets. For Asian charsets, it is recommended to stick with the Base64 encoding.
     275=== ''501, 5.5.4 Invalid Address'' error ===
     277On IIS 6.0 you could get a
     279Failure sending notification on change to ticket #1: SMTPHeloError: (501, '5.5.4 Invalid Address')
     281in the trac log. Have a look [ here] for instructions on resolving it.
     285See also: TracTickets, TracIni, TracGuide