From 17ccd5e6648a3bde1995bac58a12be5b43969f99 Mon Sep 17 00:00:00 2001 From: dm03514 Date: Thu, 10 Nov 2011 23:17:24 -0500 Subject: Send Email Command Feature 131 --- askbot/management/commands/send_email.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 askbot/management/commands/send_email.py diff --git a/askbot/management/commands/send_email.py b/askbot/management/commands/send_email.py new file mode 100644 index 00000000..8f67ad2f --- /dev/null +++ b/askbot/management/commands/send_email.py @@ -0,0 +1,29 @@ +from askbot.utils.mail import send_mail +from django.core.exceptions import ValidationError +from django.core.management.base import BaseCommand, CommandError +from django.core.validators import validate_email + +class Command(BaseCommand): + args = '' + help = 'Sends a test email to the specified email address' + + def handle(self, *args, **options): + + if len(args) != 1: + raise CommandError('Recipients email address required') + + try: + validate_email(args[0]) + except ValidationError: + raise CommandError('%s is not a valid email address' % (args[0])) + + send_mail( + subject_line = 'Askbot Mail Test', + body_text = 'Askbot Mail Test', + recipient_list = [args[0]], + ) + + + + + -- cgit v1.2.3-1-g7c22