-### Vaguely Customizable Options ###
+### Options for configuring rss2email ###
# The email address messages are from by default:
DEFAULT_FROM = "bozo@dev.null.invalid"
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'
# 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
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",
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'
# 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
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:
if AUTHREQUIRED:
try:
smtpserver.ehlo()
- smtpserver.starttls()
+ if not SMTP_SSL: smtpserver.starttls()
smtpserver.ehlo()
smtpserver.login(SMTP_USER, SMTP_PASS)
except KeyboardInterrupt:
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]
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
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 ###
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,))
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(':')
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'"
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)