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
|
|
|
|
|
2016-04-02 17:03:29 +02:00
|
|
|
from django.conf import settings
|
2017-01-20 08:12:49 +01:00
|
|
|
from django.core.mail import mail_admins, mail_managers, send_mail
|
|
|
|
from django.core.management.commands import sendtestemail
|
2016-04-02 17:03:29 +02:00
|
|
|
|
2017-01-20 08:12:49 +01:00
|
|
|
class Command(sendtestemail.Command):
|
|
|
|
def handle(self, *args, **kwargs):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **str) -> None
|
2016-04-02 17:03:29 +02:00
|
|
|
subject = "Zulip Test email"
|
2017-01-20 08:12:49 +01:00
|
|
|
message = ("Success! If you receive this message, you've "
|
|
|
|
"successfully configured sending email from your "
|
|
|
|
"Zulip server.")
|
2016-04-02 17:03:29 +02:00
|
|
|
sender = settings.DEFAULT_FROM_EMAIL
|
2017-01-20 08:12:49 +01:00
|
|
|
send_mail(subject, message, sender, kwargs['email'])
|
|
|
|
|
|
|
|
if kwargs['managers']:
|
|
|
|
mail_managers(subject, "This email was sent to the site managers.")
|
2016-04-02 17:03:29 +02:00
|
|
|
|
2017-01-20 08:12:49 +01:00
|
|
|
if kwargs['admins']:
|
|
|
|
mail_admins(subject, "This email was sent to the site admins.")
|