Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/submit_email/bin/send_mass_email.py

Issue 29326140: Isssue 3020 - Add a script to disaptch mass emails (Closed)
Patch Set: Get template in advance Created Sept. 8, 2015, 6:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sitescripts/submit_email/bin/__init__.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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)
OLDNEW
« no previous file with comments | « sitescripts/submit_email/bin/__init__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld