1 # Copyright (C) 2004-2013 Aaron Swartz
5 # Etienne Millon <me@emillon.org>
7 # Lindsey Smith <lindsey.smith@gmail.com>
9 # Martin 'Joey' Schulze
11 # W. Trevor King <wking@tremily.us>
13 # This file is part of rss2email.
15 # rss2email is free software: you can redistribute it and/or modify it under
16 # the terms of the GNU General Public License as published by the Free Software
17 # Foundation, either version 2 of the License, or (at your option) version 3 of
20 # rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License along with
25 # rss2email. If not, see <http://www.gnu.org/licenses/>.
27 """Per-user rss2email configuration
30 import collections as _collections
31 import configparser as _configparser
33 import html2text as _html2text
36 class Config (_configparser.ConfigParser):
37 def __init__(self, dict_type=_collections.OrderedDict,
38 interpolation=_configparser.ExtendedInterpolation(),
40 super(Config, self).__init__(
41 dict_type=dict_type, interpolation=interpolation, **kwargs)
43 def _setup(self, section='DEFAULT'):
44 _html2text.UNICODE_SNOB = self.getboolean(
45 section, 'unicode-snob', fallback=False)
46 _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
47 section, 'links-after-each-paragaph', fallback=False)
48 _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
53 # setup defaults for feeds that don't customize
54 CONFIG['DEFAULT'] = _collections.OrderedDict((
56 # The email address messages are from by default
57 ('from', 'user@rss2email.invalid'),
58 # Transfer-Encoding. For local mailing it is safe and
59 # convient to use 8bit.
60 ('use-8bit', str(False)),
61 # True: Only use the 'from' address.
62 # False: Use the email address specified by the feed, when possible.
63 ('force-from', str(False)),
64 # True: Use the publisher's email if you can't find the author's.
65 # False: Just use the 'from' email instead.
66 ('use-publisher-email', str(False)),
67 # Only use the feed email address rather than friendly name
69 ('friendly-name', str(True)),
70 # Set this to default To email addresses.
74 # Set an HTTP proxy (e.g. 'http://your.proxy.here:8080/')
76 # Set the timeout (in seconds) for feed server response
77 ('feed-timeout', str(60)),
80 # True: Fetch, process, and email feeds.
81 # False: Don't fetch, process, or email feeds
82 ('active', str(True)),
83 # True: Generate Date header based on item's date, when possible.
84 # False: Generate Date header based on time sent.
85 ('date-header', str(False)),
86 # A comma-delimited list of some combination of
87 # ('issued', 'created', 'modified', 'expired')
88 # expressing ordered list of preference in dates
89 # to use for the Date header of the email.
90 ('date-header-order', 'modified, issued, created, expired'),
91 # Set this to add bonus headers to all emails
92 # Example: bonus-header = 'Approved: joe@bob.org'
94 # True: Receive one email per post.
95 # False: Receive an email every time a post changes.
96 ('trust-guid', str(True)),
97 # To most correctly encode emails with international
98 # characters, we iterate through the list below and use the
99 # first character set that works.
100 ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
101 # User processing hooks. Note the space after the module name.
102 # Example: post-process = 'rss2email.post_process.downcase downcase_message'
103 ('post-process', ''),
105 # True: Send text/html messages when possible.
106 # False: Convert HTML to plain text.
107 ('html-mail', str(False)),
108 # Optional CSS styling
109 ('use-css', str(False)),
112 ' font: 18pt Georgia, "Times New Roman";\n'
115 ' font: 12pt Arial;\n'
118 ' font: 12pt Arial;\n'
119 ' font-weight: bold;\n'
123 ' font-family: monospace;\n'
126 ' background: #e0ecff;\n'
127 ' border-bottom: solid 4px #c3d9ff;\n'
129 ' margin-top: 0px;\n'
133 ' font-size: 20px;\n'
134 ' text-decoration: none;\n'
137 ' background: #c3d9ff;\n'
138 ' border-top: solid 4px #c3d9ff;\n'
140 ' margin-bottom: 0px;\n'
143 ' border: solid 4px #c3d9ff;\n'
146 ' margin-left: 5px;\n'
147 ' margin-right: 5px;\n'
150 # Use Unicode characters instead of their ascii psuedo-replacements
151 ('unicode-snob', str(False)),
152 # Put the links after each paragraph instead of at the end.
153 ('links-after-each-paragraph', str(False)),
154 # Wrap long lines at position. 0 for no wrapping.
155 ('body-width', str(0)),
158 # True: Use SMTP_SERVER to send mail.
159 # False: Use sendmail (or compatible) to send mail.
160 ('use-smtp', str(False)),
161 ('sendmail', '/usr/sbin/sendmail'), # Path to sendmail (or compatible)
162 ('smtp-server', 'smtp.yourisp.net:25'), ('smtp-auth', str(False)), # set to True to use SMTP AUTH
163 ('smtp-username', 'username'), # username for SMTP AUTH
164 ('smtp-password', 'password'), # password for SMTP AUTH
165 ('smtp-ssl', str(False)), # Connect to the SMTP server using SSL
168 # Verbosity (one of 'error', 'warning', 'info', or 'debug').
169 ('verbose', 'warning'),