From ebdd5374936c91e71b05d341d69301295005cef5 Mon Sep 17 00:00:00 2001 From: Lindsey Smith Date: Fri, 12 Nov 2010 12:00:00 +0000 Subject: [PATCH] Bump to version 2.69. --- CHANGELOG | 8 +++++++- config.py | 25 ++++++++++++++++++++++++- rss2email.py | 44 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3ca50ad..208fd56 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,13 @@ +v2.69 (2010-11-12) + * Added support for connecting to SMTP server via SSL, see SMTP_SSL option + * Improved backwards compatibility by fixing issue with listing feeds when run with older Python versions + * Added selective feed email overrides through OVERRIDE_EMAIL and DEFAULT_EMAIL options + * Added NO_FRIENDLY_NAME to from from address only without the friendly name + * Added X-RSS-URL header in each message with the link to the original item + v2.68 (2010-10-01) * Added ability to pause/resume checking of individual feeds through pause and unpause commands * Added ability to import and export OPML feed lists through importopml and exportopml commands - v2.67 (2010-09-21) * Fixed entries that include an id which is blank (i.e., an empty string) were being resent diff --git a/config.py b/config.py index ba2ef93..9575962 100755 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -### Vaguely Customizable Options ### +### Options for configuring rss2email ### # The email address messages are from by default: DEFAULT_FROM = "bozo@dev.null.invalid" @@ -49,6 +49,12 @@ AUTHREQUIRED = 0 # if you need to use SMTP AUTH set to 1 SMTP_USER = 'username' # for SMTP AUTH, set SMTP username here SMTP_PASS = 'password' # for SMTP AUTH, set SMTP password here +# Connect to the SMTP server using SSL + +SMTP_SSL = 0 + + + # Set this to add a bonus header to all emails (start with '\n'). BONUS_HEADER = '' # Example: BONUS_HEADER = '\nApproved: joe@bob.org' @@ -56,6 +62,23 @@ BONUS_HEADER = '' # 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 default From email addresses. Keys are feed URLs, values are new email addresses. + +DEFAULT_EMAIL = {} + + +# Only use the email from address rather than friendly name plus email address + +NO_FRIENDLY_NAME = 0 + + + # Set this to override the timeout (in seconds) for feed server response FEED_TIMEOUT = 60 diff --git a/rss2email.py b/rss2email.py index f23f788..c752635 100755 --- a/rss2email.py +++ b/rss2email.py @@ -15,7 +15,7 @@ Usage: opmlexport opmlimport filename """ -__version__ = "2.68" +__version__ = "2.69" __author__ = "Lindsey Smith (lindsey@allthingsrss.com)" __copyright__ = "(C) 2004 Aaron Swartz. GNU GPL 2 or 3." ___contributors__ = ["Dean Jackson", "Brian Lalor", "Joey Hess", @@ -77,6 +77,9 @@ AUTHREQUIRED = 0 # if you need to use SMTP AUTH set to 1 SMTP_USER = 'username' # for SMTP AUTH, set SMTP username here SMTP_PASS = 'password' # for SMTP AUTH, set SMTP password here +# Connect to the SMTP server using SSL +SMTP_SSL = 0 + # Set this to add a bonus header to all emails (start with '\n'). BONUS_HEADER = '' # Example: BONUS_HEADER = '\nApproved: joe@bob.org' @@ -84,6 +87,15 @@ BONUS_HEADER = '' # 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 default From email addresses. Keys are feed URLs, values are new email addresses. +DEFAULT_EMAIL = {} + +# Only use the email from address rather than friendly name plus email address +NO_FRIENDLY_NAME = 0 + # Set this to override the timeout (in seconds) for feed server response FEED_TIMEOUT = 60 @@ -169,7 +181,11 @@ def send(sender, recipient, subject, body, contenttype, extraheaders=None, smtps import smtplib try: - smtpserver = smtplib.SMTP(SMTP_SERVER) + if SMTP_SSL: + smtpserver = smtplib.SMTP_SSL() + else: + smtpserver = smtplib.SMTP() + smtpserver.connect(SMTP_SERVER) except KeyboardInterrupt: raise except Exception, e: @@ -183,7 +199,7 @@ def send(sender, recipient, subject, body, contenttype, extraheaders=None, smtps if AUTHREQUIRED: try: smtpserver.ehlo() - smtpserver.starttls() + if not SMTP_SSL: smtpserver.starttls() smtpserver.ehlo() smtpserver.login(SMTP_USER, SMTP_PASS) except KeyboardInterrupt: @@ -392,6 +408,8 @@ def getID(entry): def getName(r, entry): """Get the best name.""" + if NO_FRIENDLY_NAME: return '' + feed = r.feed if hasattr(r, "url") and r.url in OVERRIDE_FROM.keys(): return OVERRIDE_FROM[r.url] @@ -414,11 +432,16 @@ def getName(r, entry): return name -def getEmail(feed, entry): +def getEmail(r, entry): """Get the best email_address.""" - + + feed = r.feed + if FORCE_FROM: return DEFAULT_FROM + if r.url in OVERRIDE_EMAIL.keys(): + return OVERRIDE_EMAIL[r.url] + if 'email' in entry.get('author_detail', []): return entry.author_detail.email @@ -434,6 +457,9 @@ def getEmail(feed, entry): if feed.get("errorreportsto", ''): return feed.errorreportsto + if r.url in DEFAULT_EMAIL.keys(): + return DEFAULT_EMAIL[r.url] + return DEFAULT_FROM ### Simple Database of Feeds ### @@ -642,7 +668,7 @@ def run(num=None): link = entry.get('link', "") - from_addr = getEmail(r.feed, entry) + from_addr = getEmail(r, entry) name = h2t.unescape(getName(r, entry)) fromhdr = formataddr((name, from_addr,)) @@ -650,7 +676,7 @@ def run(num=None): subjecthdr = title datehdr = time.strftime("%a, %d %b %Y %H:%M:%S -0000", datetime) useragenthdr = "rss2email" - extraheaders = {'Date': datehdr, 'User-Agent': useragenthdr, 'X-RSS-Feed': f.url, 'X-RSS-ID': id} + extraheaders = {'Date': datehdr, 'User-Agent': useragenthdr, 'X-RSS-Feed': f.url, 'X-RSS-ID': id, 'X-RSS-URL': link} if BONUS_HEADER != '': for hdr in BONUS_HEADER.strip().splitlines(): pos = hdr.strip().find(':') @@ -756,7 +782,7 @@ def list(): print "default email:", default_to else: ifeeds = feeds; i = 0 for f in ifeeds: - active = '[*]' if f.active else '[ ]' + active = ('[ ]', '[*]')[f.active] print `i`+':',active, f.url, '('+(f.to or ('default: '+default_to))+')' if not (f.to or default_to): print " W: Please define a default address with 'r2e email emailaddress'" @@ -823,7 +849,7 @@ def toggleactive(n, active): elif n >= len(feeds): print >>warn, "W: no such feed" else: - action = 'Unpausing' if active else 'Pausing' + action = ('Pausing', 'Unpausing')[active] print >>warn, "%s feed %s" % (action, feeds[n].url) feeds[n].active = active unlock(feeds, feedfileObject) -- 2.26.2