Edgewall Software

Ticket #3447 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 21 months ago

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

Reported by: tuttle@… Owned by: jonas
Priority: normal Milestone:
Component: ticket system Version: 0.9.6
Severity: trivial Keywords: notification email
Cc: tuttle@…

Description

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,

Vlada

Patch:

--- Notify.py.orig      2006-07-21 14:55:35.000000000 +0200
+++ Notify.py   2006-07-21 15:29:11.000000000 +0200
@@ -21,11 +21,11 @@
 from trac.web.main import populate_hdf
 
 import md5
 import time
 import smtplib
+import pwd
 
 class Notify:
     """Generic notification class for Trac. Subclass this to implement
     different methods."""
 
@@ -132,11 +132,12 @@
         msg['X-Trac-Project'] =  projname
         msg['X-URL'] =  self.config.get('project','url')
         msg['Subject'] = Header(self.subject, 'utf-8')
         msg['From'] = '%s <%s>' % (projname, self.from_email)
         msg['Sender'] = self.from_email
-        msg['Reply-To'] = self.replyto_email
+        if self.replyto_email:
+            msg['Reply-To'] = self.replyto_email
         msg['To'] = rcpt
         msg['Date'] = formatdate()
         for hdr in mime_headers.keys():
             msg[hdr] = mime_headers[hdr]
         self.env.log.debug("Sending SMTP notification to %s on port %d"
@@ -268,10 +269,12 @@
     def get_recipients(self, tktid):
         notify_reporter = self.config.getbool('notification',
                                               'always_notify_reporter')
         notify_owner = self.config.getbool('notification',
                                            'always_notify_owner')
+        fallback_local_email = self.config.getbool('notification',
+                                                   'fallback_local_email')
 
         recipients = self.prev_cc
         cursor = self.db.cursor()
 
         # Harvest email addresses from the cc, reporter, and owner fields
@@ -297,15 +300,22 @@
         if acc:
             recipients += acc.replace(',', ' ').split()
 
         # now convert recipients into email addresses where necessary
         emails = []
+        recip_local_hostname = self.from_email[self.from_email.find('@') + 1:]
         for recipient in recipients:
             if recipient.find('@') >= 0:
                 emails.append(recipient)
             elif self.email_map.has_key(recipient):
                 emails.append(self.email_map[recipient])
+            elif fallback_local_email:
+                try:
+                  pwd.getpwnam(recipient)
+                  emails.append(recipient + '@' + recip_local_hostname)
+                except KeyError:
+                  pass
 
         # Remove duplicates
         result = []
         for e in emails:
             if e not in result:
@@ -316,11 +326,11 @@
         """Generate a predictable, but sufficiently unique message ID."""
         s = '%s.%08d.%d.%s' % (self.config.get('project', 'url'),
                                int(self.ticket.id), modtime, rcpt)
         dig = md5.new(s).hexdigest()
         host = self.from_email[self.from_email.find('@') + 1:]
-        msgid = '<%03d.%s@%s>' % (len(s), dig, host)
+        msgid = '<trac.%03d.%s@%s>' % (len(s), dig, host)
         return msgid
 
     def send(self, rcpt):
         hdrs = {}
         hdrs['Message-ID'] = self.get_message_id(rcpt, self.modtime)

Attachments

Change History

  Changed 2 years ago by eblot

  • component changed from general to ticket 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   Changed 2 years ago by Markus Tacker <m@…>

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.

  Changed 2 years ago by anonymous

This is a duplicate of #395

  Changed 2 years ago by sid

  • keywords notification email added
  • summary changed from Email Notification: Local users, Reply-To, Message-Id (patch) to [patch] Email Notification: Local users, Reply-To, Message-Id

No, it is not a duplicate of #395.

  Changed 2 years ago by eblot

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.

  Changed 21 months ago by cboos

  • status changed from new to closed
  • resolution set to wontfix

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)

Add/Change #3447 ([patch] Email Notification: Local users, Reply-To, Message-Id)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from jonas. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.