On Thu, Aug 09, 2007 at 08:23:56PM -0700, Joey Hess wrote:
> Bernhard Kauer wrote:
> > The ability to override the From: field of the mail via
> > OVERRIDE_FROM is misleading. It just allows to override
> > the From: name, but not the email address. The attached
> > patch correct this. Additionally it is an simpler way
> > as #349061 proposes to get a mail that is easy filterable
> > by procmail.
>
> Won't changing what OVERRIDE_FROM currently does break existing users of
> it? Seems that something would need to be done to handle current uses of
> OVERRIDE_FROM.
Yep, that's a problem. I added yet another config option named OVERRIDE_EMAIL
instead of reusing the OVERRIDE_FROM one. Should be backward compatible now...
Thanks,
Bernhard
--- rss2email.py.old 2007-08-09 17:24:12.000000000 +0200
+++ rss2email.py 2007-08-20 18:54:05.000000000 +0200
@@ -74,6 +74,9 @@
# Set this to override From addresses. Keys are feed URLs, values are new titles.
OVERRIDE_FROM = {}
+# Set this to override From email addresses. Keys are feed URLs, values are new emails.
+OVERRIDE_EMAIL = {}
+
# Set this to override the timeout (in seconds) for feed server response
FEED_TIMEOUT = 60
@@ -368,11 +371,15 @@
return name
-def getEmail(feed, entry):
+def getEmail(r, entry):
"""Get the best email_address."""
if FORCE_FROM: return DEFAULT_FROM
+ feed = r.feed
+ if r.url in OVERRIDE_EMAIL.keys():
+ return OVERRIDE_EMAIL[r.url]
+
if 'email' in entry.get('author_detail', []):
return entry.author_detail.email
@@ -576,7 +583,7 @@
link = entry.get('link', "")
- from_addr = getEmail(r.feed, entry)
+ from_addr = getEmail(r, entry)
name = getName(r, entry)
fromhdr = '"'+ name + '" <' + from_addr + ">"