mirror of https://github.com/zulip/zulip.git
Add management command to test sending email.
Fixes: #622. [With cleanups/doc tweaks by tabbott]
This commit is contained in:
parent
e0ef1a991e
commit
909b0635c8
|
@ -148,8 +148,11 @@ need to do some additional setup documented in the `settings.py` template:
|
|||
|
||||
* For Google authentication, you need to follow the configuration
|
||||
instructions around `GOOGLE_OAUTH2_CLIENT_ID` and `GOOGLE_CLIENT_ID`.
|
||||
|
||||
* For Email authentication, you will need to follow the configuration
|
||||
instructions around outgoing SMTP from Django.
|
||||
instructions for outgoing SMTP from Django. You can use `manage.py
|
||||
send_test_email username@example.com` to test whether you've
|
||||
successfully configured outgoing SMTP.
|
||||
|
||||
You should be able to login now. If you get an error, check
|
||||
`/var/log/zulip/errors.log` for a traceback, and consult the next
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
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):
|
||||
parser.add_argument('to', metavar='<to>', type=str,
|
||||
help="email of user to send the email")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
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])
|
|
@ -61,6 +61,9 @@ SSO_APPEND_DOMAIN = None
|
|||
# that account as "less secure":
|
||||
# https://support.google.com/mail/answer/14257.
|
||||
#
|
||||
# You can quickly test your sending email configuration using:
|
||||
# ./manage.py send_test_email username@example.com
|
||||
#
|
||||
# A common problem is hosting providers that block outgoing SMTP traffic.
|
||||
#
|
||||
# With the exception of reading EMAIL_HOST_PASSWORD from
|
||||
|
|
Loading…
Reference in New Issue