Added the option "smtp-ssl-protocol" to make STARTTLS work on Python 3.3+
[rss2email.git] / rss2email / config.py
index 4e0dbc91219c998b82a2a09f45ff38e95768715d..78c4fb19fa5cd9a295a02207cec83165fc6dac74 100644 (file)
@@ -41,12 +41,19 @@ class Config (_configparser.ConfigParser):
         super(Config, self).__init__(
             dict_type=dict_type, interpolation=interpolation, **kwargs)
 
-    def _setup(self, section='DEFAULT'):
+    def setup_html2text(self, section='DEFAULT'):
+        """Setup html2text globals to match our configuration
+
+        Html2text unfortunately uses globals (instead of keyword
+        arguments) to configure its conversion.
+        """
+        if section not in self:
+            section = 'DEFAULT'
         _html2text.UNICODE_SNOB = self.getboolean(
-            section, 'unicode-snob', fallback=False)
+            section, 'unicode-snob')
         _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
-            section, 'links-after-each-paragaph', fallback=False)
-        _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
+            section, 'links-after-each-paragraph')
+        _html2text.BODY_WIDTH = self.getint(section, 'body-width')
 
 
 CONFIG = Config()
@@ -65,9 +72,11 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # True: Use the publisher's email if you can't find the author's.
         # False: Just use the 'from' email instead.
         ('use-publisher-email', str(False)),
-        # Only use the feed email address rather than friendly name
-        # plus email address
-        ('friendly-name', str(True)),
+        # If empty, only use the feed email address rather than
+        # friendly name plus email address.  Available attributes may
+        # include 'feed', 'feed-title', 'author', and 'publisher', but
+        # only 'feed' is guaranteed.
+        ('name-format', '{feed-title}: {author}'),
         # Set this to default To email addresses.
         ('to', ''),
 
@@ -81,6 +90,9 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # True: Fetch, process, and email feeds.
         # False: Don't fetch, process, or email feeds
         ('active', str(True)),
+        # True: Send a single, multi-entry email per feed per rss2email run.
+        # False: Send a single email per entry.
+        ('digest', str(False)),
         # True: Generate Date header based on item's date, when possible.
         # False: Generate Date header based on time sent.
         ('date-header', str(False)),
@@ -95,6 +107,12 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # True: Receive one email per post.
         # False: Receive an email every time a post changes.
         ('trust-guid', str(True)),
+        # True: Receive one email per unique link url.
+        # False: Defer to trust-guid preference.
+        # Toggling this for existing feeds may result in duplicates,
+        # because the old entries will not be recorded under their new
+        # link-based ids.
+        ('trust-link', str(False)),
         # To most correctly encode emails with international
         # characters, we iterate through the list below and use the
         # first character set that works.
@@ -102,6 +120,12 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         # User processing hooks.  Note the space after the module name.
         # Example: post-process = 'rss2email.post_process.downcase downcase_message'
         ('post-process', ''),
+        # User processing hooks for digest messages.  If 'digest' is
+        # enabled, the usual 'post-process' hook gets to massage the
+        # per-entry messages, but this hook is called with the full
+        # digest message before it is mailed.
+        # Example: digest-post-process = 'rss2email.post_process.downcase downcase_message'
+        ('digest-post-process', ''),
         ## HTML conversion
         # True: Send text/html messages when possible.
         # False: Convert HTML to plain text.
@@ -156,14 +180,26 @@ CONFIG['DEFAULT'] = _collections.OrderedDict((
         ('body-width', str(0)),
 
         ### Mailing
+        # Select protocol from: sendmail, smtp, imap
+        ('email-protocol', 'sendmail'),
         # True: Use SMTP_SERVER to send mail.
-        # False: Use sendmail (or compatible) to send mail.
-        ('use-smtp', str(False)),
+        # Sendmail (or compatible) configuration
         ('sendmail', '/usr/sbin/sendmail'),  # Path to sendmail (or compatible)
-        ('smtp-server', 'smtp.yourisp.net:25'),        ('smtp-auth', str(False)),      # set to True to use SMTP AUTH
+        # SMTP configuration
+        ('smtp-auth', str(False)),      # set to True to use SMTP AUTH
         ('smtp-username', 'username'),  # username for SMTP AUTH
         ('smtp-password', 'password'),  # password for SMTP AUTH
+        ('smtp-server', 'smtp.yourisp.net:25'),
         ('smtp-ssl', str(False)),       # Connect to the SMTP server using SSL
+        ('smtp-ssl-protocol', 'SSLv3'), # TLS/SSL version to use on STARTTLS when not using 'smtp-ssl'
+        # IMAP configuration
+        ('imap-auth', str(False)),      # set to True to use IMAP auth.
+        ('imap-username', 'username'),  # username for IMAP authentication
+        ('imap-password', 'password'),  # password for IMAP authentication
+        ('imap-server', 'imap.yourisp.net'),
+        ('imap-port', str(143)),
+        ('imap-ssl', str(False)),       # connect to the IMAP server using SSL
+        ('imap-mailbox', 'INBOX'),      # where we should store new messages
 
         ### Miscellaneous
         # Verbosity (one of 'error', 'warning', 'info', or 'debug').