VirtualBox

Email Notification of Ticket Changes

Trac supports notification of ticket changes via email.

Email notification is useful to keep users up-to-date on tickets of interest, and also provides a convenient way to post all ticket changes to a dedicated mailing list.

Disabled by default, notification can be activated and configured in trac.ini.

Receiving Notification Mails

When reporting a new ticket or adding a comment, enter a valid email address or your Trac username in the reporter, assigned to/owner or cc field. Trac may send you an email when changes are made to the ticket, depending on how your notification preferences are configured.

Permission groups can also be entered in the CC field, to notify all members of the group.

How to use your username to receive notification mails

To receive notification mails, you can either enter a full email address or your Trac username. To get notified with a simple username or login, you need to specify a valid email address in your preferences.

Alternatively, a default domain name (smtp_default_domain) can be set in the TracIni file, see 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.

When using apache and mod_kerb for authentication against Kerberos / Active Directory, usernames take the form ([email protected]). To avoid this being interpreted as an email address, add the Kerberos domain to (ignore_domains).

Ticket attachment notifications

Since 1.0.3 Trac will send notifications when a ticket attachment is added or deleted. Usually attachment notifications will be enabled in an environment by default. To disable the attachment notifications for an environment the TicketAttachmentNotifier component must be disabled:

[components]
trac.ticket.notification.TicketAttachmentNotifier = disabled

Configuring SMTP Notification

Important: The [trac] base_url option must be configured for links in the notification message to be correctly generated.

Configuration Options

These are the available options for the [notification] section in trac.ini:

[notification]

admit_domains

在電子郵件地址中應被視為有價值的網域(逗號分隔列表)(例如localdomain)。

(無預設)
ambiguous_char_width

通知郵件表中應使用的歧義字元寬度。

如果為single,則寬度與US-ASCII中的字元相同。這是大多數用戶所期望的。 如果為double,則寬度為US-ASCII字元的兩倍。這是中日韓用戶所期望的。

single
batch_subject_template

類似於ticket_subject_template,但用於批次處理修改。 (從 1.0)

${prefix} Batch modify: ${tickets_descr}
default_format.email

分發電子郵件通知的預設格式。

text/plain
email_address_resolvers

電子郵件解析組件(逗號分隔列表)(按被調用的順序)。 如果電子郵件地址已解析,則不會調用其餘的解析器。

SessionEmailResolver
email_sender

實現IEmailSender的組件名稱。

通知系統使用此組件來發送電子郵件。 Trac當前提供SmtpEmailSender用於連接到SMTP伺服器,並提供SendmailEmailSender用於運行與sendmail兼容的可執行檔案。

SmtpEmailSender
ignore_domains

不應該被視為電子郵件地址中一部分的網域(逗號分隔列表)(針對Kerberos網域)。

(無預設)
message_id_hash

用來創建唯一Message-ID標頭的雜湊演算法。 (從 1.0.13)

md5
mime_encoding

指定電子郵件的MIME編碼方案。

支持的值有:none(默認值),如果內文為純ASCII,則為7位編碼,否則為8位。 base64,可與任何類型的內容一起使用,但可能會導致敏感的反垃圾郵件/防病毒引擎出現一些問題。 qpquoted-printable,如果不能使用8位編碼,則最適合歐洲語言(比base64更緊湊)。

none
sendmail_path

sendmail執行檔的路徑。

sendmail程序必須接受-i-f選項。

sendmail
smtp_always_bcc

始終向其發送通知的電子郵件地址列表(逗號分隔列表)。 該地址不公開(Bcc:)。

(無預設)
smtp_always_cc

始終向其發送通知的電子郵件地址列表(逗號分隔列表)。 所有收件人都可以看到該地址(Cc:)。

(無預設)
smtp_default_domain

追加到未指定地址的預設主機名/網域。 完全合格的地址不會被修改。 預設網域將附加到在用戶設置中找不到其電子郵件地址的所有用戶名。

(無預設)
smtp_enabled

啟用 email 通知

disabled
smtp_from

在電子郵件通知中使用的發件人地址。

必須至少設置smtp_fromsmtp_replyto之一,否則Trac拒絕發送通知郵件。

trac@localhost
smtp_from_author

在通知電子郵件中使用更改的作者作為發送者(例如: 新待辦事項的報告者,新留言的作者)。 如果作者未設置電子郵件地址,則改用smtp_fromsmtp_from_name。 (從 1.0)

disabled
smtp_from_name

在電子郵件通知中使用的發件人名稱。

(無預設)
smtp_password

用於通過SMTP伺服器身份驗證的密碼。

(無預設)
smtp_port

EMail 通知用 SMTP 伺服器 Port

25
smtp_replyto

在通知電子郵件中使用的回覆地址。

必須至少設置smtp_fromsmtp_replyto之一,否則Trac拒絕發送通知郵件。

trac@localhost
smtp_server

EMail 通知用 SMTP 伺服器主機名稱

localhost
smtp_subject_prefix

放在通知電子郵件的主題行之前的文字。

如果未定義設置,則將[$project_name]用作前綴。 如果不需要前綴,則指定一個空選項將禁用它。

__default__
smtp_user

用於通過SMTP伺服器身份驗證的用戶名。

(無預設)
ticket_subject_template

用於獲取通知主題的Jinja2文字模板代碼段。

模板變量記錄在 TracNotification 頁面上。

${prefix} #${ticket.id}: ${summary}
use_public_cc

To和Cc中的地址對所有收件人可見。

如果禁用此選項,則將收件人放入Bcc列表中。

disabled
use_short_addr

允許沒有主機名/網域的電子郵件地址(即僅用戶名)。

SMTP伺服器應接受這些地址,並附加FQDN或使用本地傳遞。 另請參見smtp_default_domain。 不要將此選項與公用SMTP伺服器一起使用。

disabled
use_tls

使用 SSL/TLS 寄送通知。

disabled

Example Configuration (SMTP)

[notification]
smtp_enabled = true
smtp_server = mail.example.com
smtp_from = [email protected]
smtp_replyto = [email protected]
smtp_always_cc = [email protected], [email protected]

Example Configuration (sendmail)

[notification]
smtp_enabled = true
email_sender = SendmailEmailSender
sendmail_path = /usr/sbin/sendmail
smtp_from = [email protected]
smtp_replyto = [email protected]
smtp_always_cc = [email protected], [email protected]

Subscriber Configuration

The default subscriptions are configured in the [notification-subscriber] section.

[notification-subscriber]

訂閱通知由外掛程式控制。 所有INotificationSubscriber組件都負責。 這些組件可能允許被配置透過trac.ini檔案的此區段。

更多資訊,請參見 TracNotification

可用的訂閱者:

訂閱者描述
AlwaysEmailSubscriber
CarbonCopySubscriber我加入副本的待辦事項被修改
NewTicketSubscriber任何待辦事項被建立
TicketOwnerSubscriber我負責的待辦事項被建立或修改
TicketPreviousUpdatersSubscriber我先前已更新的待辦事項被修改
TicketReporterSubscriber我報告的待辦事項被修改
TicketUpdaterSubscriber我更新一個待辦事項

Each user can override these defaults in their Notifications preferences.

For example to unsubscribe from notifications for one's own changes and comments, the rule "Never notify: I update a ticket" should be added above other subscription rules.

The subscription rule name on the left side of the = can be anything, it has no meaning outside this configuration file. The subscriber name on the right side of the = must be one of the subscribers listed in the above table.

The following attributes of default subscriptions can be configured:

  • .distributor (Default: email)
    • Other values require plugins. For example on-site requires th:OnSiteNotificationsPlugin.
  • .priority (Default: 100)
    • Smaller values override larger values.
    • If you use 0, then users will not be able to override this rule.
  • .adverb (Default: always)
    • never can be used to silence other subscription rules with higher values.
  • .format (Default: text/plain)
    • Other values require plugins. For example text/html requires th:TracHtmlNotificationPlugin.

Example Configuration (default subscriptions)

[notification-subscriber]
always_notify_owner = TicketOwnerSubscriber
always_notify_owner.distributor = email
always_notify_owner.priority = 100
always_notify_owner.adverb = always
always_notify_owner.format = text/plain

always_notify_previous_updater = TicketPreviousUpdatersSubscriber

never_notify_updater = TicketUpdaterSubscriber
never_notify_updater.adverb = never
never_notify_updater.priority = 0

notify_cc_html = CarbonCopySubscriber
notify_cc_html.format = text/html

Customizing the email subject

The email subject can be customized with the ticket_subject_template option, which contains a Genshi text template snippet. The default value is:

${prefix} #${ticket.id}: ${summary}

The following variables are available in the template:

  • changes: The ticket changes (prepared by Ticket.get_change).
  • env: The project environment (see env.py).
  • prefix: The prefix defined in smtp_subject_prefix.
  • summary: The ticket summary, with the old value if the summary was edited.
  • ticket: The ticket model object (see model.py). Individual ticket fields can be addressed by appending the field name separated by a dot, eg ${ticket.milestone}.

Customizing the email content

The notification email 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 is:

${ticket_body_hdr}
${ticket_props}
# if ticket.new:
${ticket.description}
# else:
#   if changes_body:
${_('Changes (by %(author)s):', author=change.author)}

${changes_body}
#   endif
#   if changes_descr:
#     if not changes_body and not change.comment and change.author:
${_('Description changed by %(author)s:', author=change.author)}
#     endif
${changes_descr}
--
#   endif
#   if change.comment:

${_('Comment:') if changes_body else
  _('Comment (by %(author)s):', author=change.author)}

${change.comment}
#   endif
# endif
${'-- '}
${_('Ticket URL: <%(link)s>', link=ticket.link)}
${project.name} <${project.url or abs_href()}>
${project.descr}

See the cookbook for additional template customization recipes.

Sample Email

#42: testing
---------------------------+------------------------------------------------
       Id:  42             |      Status:  assigned
Component:  report system  |    Modified:  Fri Apr  9 00:04:31 2004
 Severity:  major          |   Milestone:  0.9
 Priority:  lowest         |     Version:  0.6
    Owner:  anonymous      |    Reporter:  [email protected]
---------------------------+------------------------------------------------
Changes:
  * component:  changeset view => search system
  * priority:  low => highest
  * owner:  jonas => anonymous
  * cc:  [email protected] =>
         [email protected], [email protected]
  * status:  new => assigned

Comment:
I'm interested too!

--
Ticket URL: <http://example.com/trac/ticket/42>
My Project <http://myproj.example.com/>

Using GMail as the SMTP relay host

Use the following configuration snippet:

[notification]
smtp_enabled = true
use_tls = true
mime_encoding = base64
smtp_server = smtp.gmail.com
smtp_port = 587
smtp_user = user
smtp_password = password

where user and password match an existing GMail account, ie the ones you use to log in on https://gmail.com.

Alternatively, you can use smtp_port = 25.
You should not use smtp_port = 465. Doing so may deadlock your ticket submission. Port 465 is reserved for the SMTPS protocol, which is not supported by Trac. See #7107 for details.

Troubleshooting

If notifications are not working, inspect the log for error messages.

Notification errors are not always reported through the web interface, so the user who submits a change or creates a ticket may not get notified about a notification failure. The Trac administrator needs to look at the log to find the error message and traceback.

Permission denied error

Typical error message:

  ...
  File ".../smtplib.py", line 303, in connect
    raise socket.error, msg
  error: (13, 'Permission denied')

This error usually comes from a security settings on the server: many Linux distributions do not allow the web server (Apache, ...) to post email messages to the local SMTP server.

Many users get confused when their manual attempts to contact the SMTP server succeed:

telnet localhost 25

This is because a regular user may connect to the SMTP server, but the web server cannot:

sudo -u www-data telnet localhost 25

In 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 in the Trac MailingList archive.

Relevant ML threads:

For SELinux in Fedora 10:

$ setsebool -P httpd_can_sendmail 1

Suspected spam error

Some SMTP servers may reject the notification email sent by Trac.

The 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, change the default encoding to "quoted-printable" using the mime_encoding option.

Quoted printable encoding works better with languages that use one of the Latin charsets. For Asian charsets, stick with the Base64 encoding.


See also: TracTickets, TracIni, TracGuide, TracDev/NotificationApi

最後修改 18 月 前 最後修訂日期 2023-6-2 上午10:32:55
注意: 瀏覽 TracWiki 來幫助您使用wiki功能

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette