| OLD | NEW |
| (Empty) |
| 1 # coding: utf-8 | |
| 2 | |
| 3 # This file is part of the Adblock Plus web scripts, | |
| 4 # Copyright (C) 2006-2015 Eyeo GmbH | |
| 5 # | |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | |
| 7 # it under the terms of the GNU General Public License version 3 as | |
| 8 # published by the Free Software Foundation. | |
| 9 # | |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | |
| 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 # GNU General Public License for more details. | |
| 14 # | |
| 15 # You should have received a copy of the GNU General Public License | |
| 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | |
| 18 import sys | |
| 19 import argparse | |
| 20 import logging | |
| 21 | |
| 22 from sitescripts.utils import get_template, sendMail | |
| 23 | |
| 24 parser = argparse.ArgumentParser(description='Renders the given email template ' | |
| 25 'and dispatches emails to the ' | |
| 26 'addresses given on stdin') | |
| 27 parser.add_argument('template') | |
| 28 parser.add_argument('--log-level', default='INFO') | |
| 29 | |
| 30 if __name__ == '__main__': | |
| 31 args = parser.parse_args() | |
| 32 logging.basicConfig(level=args.log_level) | |
| 33 template = get_template(args.template, False) | |
| 34 | |
| 35 for recipient in sys.stdin: | |
| 36 recipient = recipient.strip() | |
| 37 try: | |
| 38 sendMail(template, {'recipient': recipient}) | |
| 39 except Exception: | |
| 40 logging.error('Failed to send email to %r', recipient, exc_info=True) | |
| 41 else: | |
| 42 logging.info('Sent email to %r', recipient) | |
| OLD | NEW |