Edgewall Software

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#3447 closed enhancement (wontfix)

[patch] Email Notification: Local users, Reply-To, Message-Id

Reported by: tuttle@… Owned by: Jonas Borgström
Priority: normal Milestone:
Component: ticket system Version: 0.9.6
Severity: trivial Keywords: notification email
Cc: tuttle@… Branch:
Release Notes:
API Changes:


Patch components:

1) I use Trac on Linux system, where I use UNIX usernames for web auth. With this patch and new boolean configuration option, my users do not have to fill-in their e-mail address to be notified (they're concated automatically for them).

2) Reply-To header is added to message only when reply-to configuration option is given (for nicer e-mail displaying).

3) 'trac.' is prepended to Message-Id for quick distinguish in maillog.

So far, patch is unix specific (uses module pwd).

Thanks for consideration,



  • Notify.py

    old new (this hunk was shorter than expected)  
    2121from trac.web.main import populate_hdf
    2323import md5
    2424import time
    2525import smtplib
     26import pwd
    2728class Notify:
    2829    """Generic notification class for Trac. Subclass this to implement
    2930    different methods."""
    132132        msg['X-Trac-Project'] =  projname
    133133        msg['X-URL'] =  self.config.get('project','url')
    134134        msg['Subject'] = Header(self.subject, 'utf-8')
    135135        msg['From'] = '%s <%s>' % (projname, self.from_email)
    136136        msg['Sender'] = self.from_email
    137         msg['Reply-To'] = self.replyto_email
     137        if self.replyto_email:
     138            msg['Reply-To'] = self.replyto_email
    138139        msg['To'] = rcpt
    139140        msg['Date'] = formatdate()
    140141        for hdr in mime_headers.keys():
    141142            msg[hdr] = mime_headers[hdr]
    142143        self.env.log.debug("Sending SMTP notification to %s on port %d"
    268269    def get_recipients(self, tktid):
    269270        notify_reporter = self.config.getbool('notification',
    270271                                              'always_notify_reporter')
    271272        notify_owner = self.config.getbool('notification',
    272273                                           'always_notify_owner')
     274        fallback_local_email = self.config.getbool('notification',
     275                                                   'fallback_local_email')
    274277        recipients = self.prev_cc
    275278        cursor = self.db.cursor()
    277280        # Harvest email addresses from the cc, reporter, and owner fields
    297300        if acc:
    298301            recipients += acc.replace(',', ' ').split()
    300303        # now convert recipients into email addresses where necessary
    301304        emails = []
     305        recip_local_hostname = self.from_email[self.from_email.find('@') + 1:]
    302306        for recipient in recipients:
    303307            if recipient.find('@') >= 0:
    304308                emails.append(recipient)
    305309            elif self.email_map.has_key(recipient):
    306310                emails.append(self.email_map[recipient])
     311            elif fallback_local_email:
     312                try:
     313                  pwd.getpwnam(recipient)
     314                  emails.append(recipient + '@' + recip_local_hostname)
     315                except KeyError:
     316                  pass
    308318        # Remove duplicates
    309319        result = []
    310320        for e in emails:
    311321            if e not in result:
    316326        """Generate a predictable, but sufficiently unique message ID."""
    317327        s = '%s.%08d.%d.%s' % (self.config.get('project', 'url'),
    318328                               int(self.ticket.id), modtime, rcpt)
    319329        dig = md5.new(s).hexdigest()
    320330        host = self.from_email[self.from_email.find('@') + 1:]
    321         msgid = '<%03d.%s@%s>' % (len(s), dig, host)
     331        msgid = '<trac.%03d.%s@%s>' % (len(s), dig, host)
    322332        return msgid
    324334    def send(self, rcpt):
    325335        hdrs = {}
    326336        hdrs['Message-ID'] = self.get_message_id(rcpt, self.modtime)

Attachments (0)

Change History (6)

comment:1 by Emmanuel Blot, 13 years ago

Component: generalticket system

Some comments:

  • As long as it is platform-specific, there are few chances that the patch get merged. It would prevent Trac from running on other platforms (Windows, …)
  • Further changes in the 0.9.x branch are now mostly for security fixes. It is unlikely that new enhancement/features get merged into this branch. 0.10 is due soon, so non-security patches would better fit this upcoming release.
  • I'm not sure to understand the call to pwd.getpwnam(), as you do not make use of the results (?)
  • Notifications for 0.10 have been reworked, and a feature that looks like the fallback email option is already available.

in reply to:  description comment:2 by Markus Tacker <m@…>, 13 years ago

Replying to tuttle@sandbox.cz:

1) I use Trac on Linux system, where I use UNIX usernames for web auth. With this patch and new boolean configuration option, my users do not have to fill-in their e-mail address to be notified (they're concated automatically for them).

notification.use_short_addr exists for that: See TracIni.

comment:3 by anonymous, 13 years ago

This is a duplicate of #395

comment:4 by sid, 13 years ago

Keywords: notification email added
Summary: Email Notification: Local users, Reply-To, Message-Id (patch)[patch] Email Notification: Local users, Reply-To, Message-Id

No, it is not a duplicate of #395.

comment:5 by Emmanuel Blot, 13 years ago

Well, either the ticket is about a patch, and should be closed as wontfix because the patch will never get merged (several issues, and not aligned on a supported Trac release), or the ticket is about missing features, and I do not think changing the summary was really required in this later case.

I think it should be closed.

comment:6 by Christian Boos, 13 years ago

Resolution: wontfix
Status: newclosed

Agreed, closing.

To tuttle@…: please have a look at the existing notification topics, and see if you can contribute to other topics (e.g. point 1. is somewhat related to #1359, although more general)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Jonas Borgström 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.