Edgewall Software

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#2365 closed enhancement (fixed)

Add default e-mail domain mapping

Reported by: mrw7mrw@… Owned by: eblot
Priority: normal Milestone: 0.10
Component: general Version: 0.9
Severity: normal Keywords: notification email patch
Cc: mrw7mrw@… hshin@… nielsen@…
Release Notes:
API Changes:


I am using Trac for an internal project, so every user has the same e-mail domain. I am also using LDAP, so I prefer to have people login with a username and not an e-mail address. At the same time, I would like people to be able to receive e-mail notifications when tickets are updated.

To accomplish this, I put together a small patch that adds a new configuration variable:

[notification] smtp_defaultdomain=mydomain.com

The patch is small and simply adds another elif statement within Notify.py:

around line 98:
        self.replyto_email = self.config.get('notification', 'smtp_replyto')
        self.from_email = self.from_email or self.replyto_email
        self.default_domain = self.config.get('notification', 'smtp_defaultdomai

around line 309:

for recipient in recipients:
            if recipient.find('@') >= 0:
            elif self.email_map.has_key(recipient):
            elif self.default_domain != '':

The idea is that if the system currently can't resolve a username to an e-mail address, it simply appends the default domain to create the e-mail address. Although this isn't suitable for projects with users from different internet domains, it is very useful for projects like mine where every user has the same e-mail domain (i.e. they are all my employees).

Attachments (3)

Notify.py (12.7 KB) - added by mrw7mrw@… 9 years ago.
Modified Notify.py
trac-default-domain-2365.patch (1.1 KB) - added by nielsen@… 9 years ago.
The same functionality as a patch
trac-default-domain-0.9stable-2851.patch (1.2 KB) - added by jornh 9 years ago.
improved the patch a bit - applies to the 0.9 stable branch

Download all attachments as: .zip

Change History (12)

Changed 9 years ago by mrw7mrw@…

Modified Notify.py

comment:1 Changed 9 years ago by eblot

  • Keywords notification email added

I also use LDAP, but as I have access to the SMTP server, I've set up the SMTP server to resolve the username into the user e-mail address, using the LDAP directory.

However, I agree that a default domain may also be useful.

comment:2 Changed 9 years ago by Matthew Williams <mrw7mrw@…>

  • Cc mrw7mrw@… added

comment:3 Changed 9 years ago by Haisoo Shin

  • Cc hshin@… added; mrw7mrw@… removed

This feature should definitely be in the next release. Very useful for small company.

comment:4 Changed 9 years ago by anonymous

  • Cc mrw7mrw@… added; hshin@… removed

Changed 9 years ago by nielsen@…

The same functionality as a patch

comment:5 Changed 9 years ago by anonymous

  • Cc mrw7mrw@… added; mrw7mrw@… removed

comment:6 Changed 9 years ago by anonymous

This is a duplicate of #464. And decided that it wasnt a neccessary enhancement.

comment:7 Changed 9 years ago by jornh

  • Keywords patch added

No this is not a duplicate of #464 which was about mapping usernames to user accounts on the host where trac is running. This is about adding an optional fallback to a default domain name that you can configure in trac.ini which is more generic.

IMHO one good argument for having this feature is in a company setting with several trac environments you would otherwise require all users to either use full email adresses in the tickets or that all users set their full email adresses under 'settings' for each separate trac environment.

See also #1286 which describes the need for adding a default domain for ticket notification mails. I think #1286 can be closed because it's essentially about the same requirement but this ticket (#2365) is better since it contains a simpler and newer patch that can be applied to trac 0.9.

Changed 9 years ago by jornh

improved the patch a bit - applies to the 0.9 stable branch

comment:8 Changed 9 years ago by eblot

  • Milestone set to 0.10
  • Owner changed from jonas to eblot
  • Status changed from new to assigned

comment:9 Changed 9 years ago by eblot

  • Resolution set to fixed
  • Status changed from assigned to closed

Should be fixed in [2936].

[notification] option to use in trac.ini is smtp_default_domain.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain eblot.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from eblot to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.