[patch] prettier and more informative comment emails

Alec Berryman <alec-93qrncnF8/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
The default email sent by the comments plugin isn't very readable.  This
patch adds formatting, labels, and additional useful information.


== begin sample old email body ==
comment text here
172.16.32.6
/home/alec/log/comments/foo-1142549941.43.cmt
http://staging.vpn.thened.net/log/foo
== end sample old email body ==


== begin sample new email body ==
Name: Alec Berryman
Email: alec-93qrncnF8/[email protected]
URL: http://www.thened.net/
Hostname: tatsu.vpn (172.16.32.6)
Entry URL: http://staging.vpn.thened.net/log/foo
Comment location: /home/alec/log/comments/foo-1142549941.43.cmt


comment text here
== end sample new email body ==
comments-pretty-email.diff (text/plain, 1.5 KB)
--- comments.py.orig	Sat Apr 15 11:43:36 2006
+++ comments.py	Sat Apr 15 11:43:53 2006
@@ -443,6 +443,7 @@
         from email.Utils import formatdate
     except ImportError:
         from rfc822 import formatdate
+    from socket import gethostbyaddr
 
     author = escape_SMTP_commands(clean_author(comment['author']))
     description = escape_SMTP_commands(comment['description'])
@@ -462,9 +463,20 @@
         message.append("From: %s" % email)
         message.append("To: %s" % config["comment_smtp_to"])
         message.append("Date: %s" % formatdate(float(comment['pubDate'])))
-        message.append("Subject: write back by %s" % author)
+        message.append("Subject: comment by %s" % author)
         message.append("")
-        message.append("%s\n%s\n%s\n%s\n" % (description, ipaddress, comment_filename, curl))
+        message.append("Name: %s" % author)
+        if comment.has_key('email'):
+            message.append("Email: %s" % comment['email'])
+        if comment.has_key('link'):
+            message.append("URL: %s" % comment['link'])
+        try:
+            message.append("Hostname: %s (%s)" % (gethostbyaddr(ipaddress)[0], ipaddress))
+        except:
+            message.append("IP: %s" % ipaddress)
+        message.append("Entry URL: %s" % curl)
+        message.append("Comment location: %s" % comment_filename)
+        message.append("\n\n%s" % description)
         server.sendmail(from_addr=email,
                         to_addrs=config['comment_smtp_to'], 
                         msg="\n".join(message))
signature.asc (application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (FreeBSD)

iD8DBQFEQNV4Aud/2YgchcQRAuWnAJ9Uv1cp7tFDCOZu8GJCMqHhqLQvQACgsvgi
HD9uAZSVQ3EcFc39rYOphPU=
=s0Jh
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.