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 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 |
| 34 for recipient in sys.stdin: |
| 35 recipient = recipient.strip() |
| 36 try: |
| 37 sendMail(args.template, {'recipient': recipient}) |
| 38 except Exception: |
| 39 logging.error('Failed to send email to %r', recipient, exc_info=True) |
| 40 else: |
| 41 logging.info('Sent email to %r', recipient) |
OLD | NEW |