2016-04-02 17:03:29 +02:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2018-05-14 21:01:48 +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
|
2018-05-14 21:01:48 +02:00
|
|
|
from django.core.management import CommandError
|
2017-01-20 08:12:49 +01:00
|
|
|
from django.core.management.commands import sendtestemail
|
2016-04-02 17:03:29 +02:00
|
|
|
|
2017-07-02 05:27:01 +02:00
|
|
|
from zerver.lib.send_email import FromAddress
|
|
|
|
|
2017-01-20 08:12:49 +01:00
|
|
|
class Command(sendtestemail.Command):
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **kwargs: str) -> None:
|
2018-05-14 21:01:48 +02:00
|
|
|
if settings.WARN_NO_EMAIL:
|
|
|
|
raise CommandError("Outgoing email not yet configured, see\n "
|
|
|
|
"https://zulip.readthedocs.io/en/latest/production/email.html")
|
2017-01-20 08:12:49 +01:00
|
|
|
message = ("Success! If you receive this message, you've "
|
|
|
|
"successfully configured sending email from your "
|
2017-09-22 22:32:22 +02:00
|
|
|
"Zulip server. Remember that you need to restart "
|
|
|
|
"the Zulip server with /home/zulip/deployments/current/scripts/restart-server "
|
|
|
|
"after changing the settings in /etc/zulip before your changes will take effect.")
|
2018-05-27 20:13:23 +02:00
|
|
|
send_mail("Zulip email test", message, FromAddress.SUPPORT, kwargs['email'])
|
2018-06-20 11:56:26 +02:00
|
|
|
send_mail("Zulip noreply email test", message, FromAddress.tokenized_no_reply_address(), kwargs['email'])
|
2017-01-20 08:12:49 +01:00
|
|
|
|
|
|
|
if kwargs['managers']:
|
2018-05-27 20:13:23 +02:00
|
|
|
mail_managers("Zulip manager email test", "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']:
|
2018-05-27 20:13:23 +02:00
|
|
|
mail_admins("Zulip admins email test", "This email was sent to the site admins.")
|