old_contents: from __future__ import absolute_import
  
  from typing import Any
  
  from argparse import ArgumentParser
  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):
          # type: (ArgumentParser) -> None
          parser.add_argument('to', metavar='<to>', type=str,
                              help="email of user to send the email")
  
      def handle(self, *args, **options):
          # type: (*Any, **str) -> None
          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])
  
new_contents: from __future__ import absolute_import
  
  from typing import Any
  
  from django.conf import settings
  from django.core.mail import mail_admins, mail_managers, send_mail
  from django.core.management.commands import sendtestemail
  
  class Command(sendtestemail.Command):
      def handle(self, *args, **kwargs):
          # type: (*Any, **str) -> None
          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
          send_mail(subject, message, sender, kwargs['email'])
  
          if kwargs['managers']:
              mail_managers(subject, "This email was sent to the site managers.")
  
          if kwargs['admins']:
              mail_admins(subject, "This email was sent to the site admins.")
  
subject: Clean code of send_test_email command.