2016-04-02 17:03:29 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
2016-04-02 17:03:29 +02:00
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from django.conf import settings
|
|
|
|
from django.core.mail import send_mail, BadHeaderError
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = """Send email to specified email address."""
|
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (ArgumentParser) -> None
|
2016-04-02 17:03:29 +02:00
|
|
|
parser.add_argument('to', metavar='<to>', type=str,
|
|
|
|
help="email of user to send the email")
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **str) -> None
|
2016-04-02 17:03:29 +02:00
|
|
|
subject = "Zulip Test email"
|
|
|
|
message = "Success! If you receive this message, you've successfully " + \
|
|
|
|
"configured sending email from your Zulip server."
|
|
|
|
sender = settings.DEFAULT_FROM_EMAIL
|
|
|
|
to = options['to']
|
|
|
|
|
|
|
|
send_mail(subject, message, sender, [to])
|