snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
81
zerver/management/commands/send_test_email.py
Normal file
81
zerver/management/commands/send_test_email.py
Normal file
@@ -0,0 +1,81 @@
|
||||
import io
|
||||
import smtplib
|
||||
from contextlib import redirect_stderr
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.mail import mail_admins, mail_managers, send_mail
|
||||
from django.core.management import CommandError
|
||||
from django.core.management.commands import sendtestemail
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.send_email import FromAddress, log_email_config_errors
|
||||
|
||||
|
||||
class Command(sendtestemail.Command):
|
||||
@override
|
||||
def handle(self, *args: Any, **kwargs: str) -> None:
|
||||
if settings.WARN_NO_EMAIL:
|
||||
raise CommandError(
|
||||
"Outgoing email not yet configured, see\n "
|
||||
"https://zulip.readthedocs.io/en/latest/production/email.html"
|
||||
)
|
||||
|
||||
log_email_config_errors()
|
||||
|
||||
if len(kwargs["email"]) == 0:
|
||||
raise CommandError(
|
||||
"Usage: /home/zulip/deployments/current/manage.py "
|
||||
"send_test_email username@example.com"
|
||||
)
|
||||
|
||||
print("If you run into any trouble, read:")
|
||||
print()
|
||||
print(" https://zulip.readthedocs.io/en/latest/production/email.html#troubleshooting")
|
||||
print()
|
||||
print("The most common error is not setting `ADD_TOKENS_TO_NOREPLY_ADDRESS=False` when")
|
||||
print("using an email provider that doesn't support that feature.")
|
||||
print()
|
||||
print("Sending 2 test emails from:")
|
||||
|
||||
message = (
|
||||
"Success! If you receive this message (and a second with a different subject), "
|
||||
"you've successfully configured sending emails from your 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."
|
||||
)
|
||||
with redirect_stderr(io.StringIO()) as f:
|
||||
smtplib.SMTP.debuglevel = 1
|
||||
try:
|
||||
sender = FromAddress.SUPPORT
|
||||
print(f" * {sender}")
|
||||
send_mail("Zulip email test", message, sender, kwargs["email"])
|
||||
|
||||
noreply_sender = FromAddress.tokenized_no_reply_address()
|
||||
print(f" * {noreply_sender}")
|
||||
send_mail("Zulip noreply email test", message, noreply_sender, kwargs["email"])
|
||||
except smtplib.SMTPException as e:
|
||||
print(f"Failed to send mails: {e}")
|
||||
print()
|
||||
print("Full SMTP log follows:")
|
||||
print(f.getvalue())
|
||||
raise CommandError("Email sending failed!")
|
||||
except OSError as e:
|
||||
print(f"Failed to send mails: {e}")
|
||||
print()
|
||||
print("Full SMTP log follows:")
|
||||
print(f.getvalue())
|
||||
print()
|
||||
print(
|
||||
"This usually means that your host or firewall is blocking outgoing SMTP traffic."
|
||||
)
|
||||
raise CommandError("Email sending failed!")
|
||||
print()
|
||||
print("Successfully sent 2 emails to {}!".format(", ".join(kwargs["email"])))
|
||||
|
||||
if kwargs["managers"]:
|
||||
mail_managers("Zulip manager email test", "This email was sent to the site managers.")
|
||||
|
||||
if kwargs["admins"]:
|
||||
mail_admins("Zulip admins email test", "This email was sent to the site admins.")
|
||||
Reference in New Issue
Block a user