email: Make path to sendmail configurable
[rss2email.git] / rss2email / config.py
1 # Copyright (C) 2004-2013 Aaron Swartz
2 #                         Brian Lalor
3 #                         Dean Jackson
4 #                         Erik Hetzner
5 #                         Etienne Millon <me@emillon.org>
6 #                         Joey Hess
7 #                         Lindsey Smith <lindsey.smith@gmail.com>
8 #                         Marcel Ackermann
9 #                         Martin 'Joey' Schulze
10 #                         Matej Cepl
11 #                         W. Trevor King <wking@tremily.us>
12 #
13 # This file is part of rss2email.
14 #
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
18 # the License.
19 #
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.
23 #
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/>.
26
27 """Per-user rss2email configuration
28 """
29
30 import collections as _collections
31 import configparser as _configparser
32
33 import html2text as _html2text
34
35
36 class Config (_configparser.ConfigParser):
37     def __init__(self, **kwargs):
38         super(Config, self).__init__(dict_type=_collections.OrderedDict)
39
40     def _setup(self, section='DEFAULT'):
41         _html2text.UNICODE_SNOB = self.getboolean(
42             section, 'unicode-snob', fallback=False)
43         _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
44             section, 'links-after-each-paragaph', fallback=False)
45         _html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
46
47
48 CONFIG = Config()
49
50 # setup defaults for feeds that don't customize
51 CONFIG['DEFAULT'] = _collections.OrderedDict((
52         ### Addressing
53         # The email address messages are from by default
54         ('from', 'user@rss2email.invalid'),
55         # Transfer-Encoding. For local mailing it is safe and
56         # convient to use 8bit.
57         ('use-8bit', str(False)),
58         # True: Only use the 'from' address.
59         # False: Use the email address specified by the feed, when possible.
60         ('force-from', str(False)),
61         # True: Use the publisher's email if you can't find the author's.
62         # False: Just use the 'from' email instead.
63         ('use-publisher-email', str(False)),
64         # Only use the feed email address rather than friendly name
65         # plus email address
66         ('friendly-name', str(True)),
67         # Set this to default To email addresses.
68         ('to', ''),
69
70         ### Fetching
71         # Set an HTTP proxy (e.g. 'http://your.proxy.here:8080/')
72         ('proxy', ''),
73         # Set the timeout (in seconds) for feed server response
74         ('feed-timeout', str(60)),
75
76         ### Processing
77         # True: Fetch, process, and email feeds.
78         # False: Don't fetch, process, or email feeds
79         ('active', str(True)),
80         # True: Generate Date header based on item's date, when possible.
81         # False: Generate Date header based on time sent.
82         ('date-header', str(False)),
83         # A comma-delimited list of some combination of
84         # ('issued', 'created', 'modified', 'expired')
85         # expressing ordered list of preference in dates
86         # to use for the Date header of the email.
87         ('date-header-order', 'modified, issued, created, expired'),
88         # Set this to add bonus headers to all emails
89         # Example: bonus-header = 'Approved: joe@bob.org'
90         ('bonus-header', ''),
91         # True: Receive one email per post.
92         # False: Receive an email every time a post changes.
93         ('trust-guid', str(True)),
94         # To most correctly encode emails with international
95         # characters, we iterate through the list below and use the
96         # first character set that works.
97         ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
98         ## HTML conversion
99         # True: Send text/html messages when possible.
100         # False: Convert HTML to plain text.
101         ('html-mail', str(False)),
102         # Optional CSS styling
103         ('use-css', str(False)),
104         ('css', (
105                 'h1 {\n'
106                 '  font: 18pt Georgia, "Times New Roman";\n'
107                 '}\n'
108                 'body {\n'
109                 '  font: 12pt Arial;\n'
110                 '}\n'
111                 'a:link {\n'
112                 '  font: 12pt Arial;\n'
113                 '  font-weight: bold;\n'
114                 '  color: #0000cc;\n'
115                 '}\n'
116                 'blockquote {\n'
117                 '  font-family: monospace;\n'
118                 '}\n'
119                 '.header {\n'
120                 '  background: #e0ecff;\n'
121                 '  border-bottom: solid 4px #c3d9ff;\n'
122                 '  padding: 5px;\n'
123                 '  margin-top: 0px;\n'
124                 '  color: red;\n'
125                 '}\n'
126                 '.header a {\n'
127                 '  font-size: 20px;\n'
128                 '  text-decoration: none;\n'
129                 '}\n'
130                 '.footer {\n'
131                 '  background: #c3d9ff;\n'
132                 '  border-top: solid 4px #c3d9ff;\n'
133                 '  padding: 5px;\n'
134                 '  margin-bottom: 0px;\n'
135                 '}\n'
136                 '#entry {\n'
137                 '  border: solid 4px #c3d9ff;\n'
138                 '}\n'
139                 '#body {\n'
140                 '  margin-left: 5px;\n'
141                 '  margin-right: 5px;\n'
142                 '}\n')),
143         ## html2text options
144         # Use Unicode characters instead of their ascii psuedo-replacements
145         ('unicode-snob', str(False)),
146         # Put the links after each paragraph instead of at the end.
147         ('links-after-each-paragraph', str(False)),
148         # Wrap long lines at position. 0 for no wrapping.
149         ('body-width', str(0)),
150
151         ### Mailing
152         # True: Use SMTP_SERVER to send mail.
153         # False: Use sendmail (or compatible) to send mail.
154         ('use-smtp', str(False)),
155         ('sendmail', '/usr/sbin/sendmail'),  # Path to sendmail (or compatible)
156         ('smtp-server', 'smtp.yourisp.net:25'),        ('smtp-auth', str(False)),      # set to True to use SMTP AUTH
157         ('smtp-username', 'username'),  # username for SMTP AUTH
158         ('smtp-password', 'password'),  # password for SMTP AUTH
159         ('smtp-ssl', str(False)),       # Connect to the SMTP server using SSL
160
161         ### Miscellaneous
162         # Verbosity (one of 'error', 'warning', 'info', or 'debug').
163         ('verbose', 'warning'),
164         ))