#3447 closed enhancement (wontfix)
[patch] Email Notification: Local users, Reply-To, Message-Id
Reported by: | 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: | |||
Internal Changes: |
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
old new (this hunk was shorter than expected) 21 21 from trac.web.main import populate_hdf 22 22 23 23 import md5 24 24 import time 25 25 import smtplib 26 import pwd 26 27 27 28 class Notify: 28 29 """Generic notification class for Trac. Subclass this to implement 29 30 different methods.""" 30 31 … … 132 132 msg['X-Trac-Project'] = projname 133 133 msg['X-URL'] = self.config.get('project','url') 134 134 msg['Subject'] = Header(self.subject, 'utf-8') 135 135 msg['From'] = '%s <%s>' % (projname, self.from_email) 136 136 msg['Sender'] = self.from_email 137 msg['Reply-To'] = self.replyto_email 137 if self.replyto_email: 138 msg['Reply-To'] = self.replyto_email 138 139 msg['To'] = rcpt 139 140 msg['Date'] = formatdate() 140 141 for hdr in mime_headers.keys(): 141 142 msg[hdr] = mime_headers[hdr] 142 143 self.env.log.debug("Sending SMTP notification to %s on port %d" … … 268 269 def get_recipients(self, tktid): 269 270 notify_reporter = self.config.getbool('notification', 270 271 'always_notify_reporter') 271 272 notify_owner = self.config.getbool('notification', 272 273 'always_notify_owner') 274 fallback_local_email = self.config.getbool('notification', 275 'fallback_local_email') 273 276 274 277 recipients = self.prev_cc 275 278 cursor = self.db.cursor() 276 279 277 280 # Harvest email addresses from the cc, reporter, and owner fields … … 297 300 if acc: 298 301 recipients += acc.replace(',', ' ').split() 299 302 300 303 # now convert recipients into email addresses where necessary 301 304 emails = [] 305 recip_local_hostname = self.from_email[self.from_email.find('@') + 1:] 302 306 for recipient in recipients: 303 307 if recipient.find('@') >= 0: 304 308 emails.append(recipient) 305 309 elif self.email_map.has_key(recipient): 306 310 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 307 317 308 318 # Remove duplicates 309 319 result = [] 310 320 for e in emails: 311 321 if e not in result: … … 316 326 """Generate a predictable, but sufficiently unique message ID.""" 317 327 s = '%s.%08d.%d.%s' % (self.config.get('project', 'url'), 318 328 int(self.ticket.id), modtime, rcpt) 319 329 dig = md5.new(s).hexdigest() 320 330 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) 322 332 return msgid 323 333 324 334 def send(self, rcpt): 325 335 hdrs = {} 326 336 hdrs['Message-ID'] = self.get_message_id(rcpt, self.modtime)
Attachments (0)
Change History (6)
comment:1 by , 18 years ago
Component: | general → ticket system |
---|
comment:2 by , 18 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:4 by , 18 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 , 18 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 , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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)
Some comments:
pwd.getpwnam()
, as you do not make use of the results (?)