add an --ip option to the sendmail command, pass the logger to send_mail_notifications, add a --file option to send from a file

This commit is contained in:
Benjamin Dauvergne 2012-05-10 11:40:06 +00:00
parent c1ff62c8c7
commit a9471920c5
1 changed files with 7 additions and 3 deletions

View File

@ -34,7 +34,8 @@ In case of failure the following return value is returned:
option_list = BaseCommand.option_list + (
make_option("--sender"),
make_option("--base-url", default="http://localhost:8000"),
make_option("--ip", default=''))
make_option("--ip", default=''),
make_option("--file"))
def handle(self, *args, **options):
mail_sender = None
@ -47,7 +48,10 @@ In case of failure the following return value is returned:
raise CommandError('Not found')
try:
mail = email.message_from_file(sys.stdin)
if 'file' in options:
mail = email.message_from_file(file(options['file']))
else:
mail = email.message_from_file(sys.stdin)
except email.errors.MessageParseError, e:
self.error('7.7.1 Error parsing message', exite_code=1)
try:
@ -154,7 +158,7 @@ In case of failure the following return value is returned:
attached_file.content.save(filename, content, save=False)
attached_file.save()
document.post()
if not views.send_mail_notifications(document, options['base_url']):
if not views.send_mail_notifications(document, options['base_url'], logger=self.logger):
transaction.rollback()
self.error('7.7.1 Document send failed because '
'some notifications could not be sent, administrators '