DjangoGirls / djangogirls

Website for DjangoGirls.org
http://djangogirls.org/
BSD 3-Clause "New" or "Revised" License
462 stars 286 forks source link

Server Error when organiser submits workshop application #609

Closed amakarudze closed 3 years ago

amakarudze commented 3 years ago

Organizers are experiencing server errors when they submit an application. The failure cannot be reproduced locally because emails do not get sent in a local environment. However, trying to send the emails on the server gave the traceback below.

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/djangogirls2/djangogirls.com/organize/emails.py", line 33, in send_application_notification
    reply_to=event_application.get_organizers_emails())
  File "/home/djangogirls2/djangogirls.com/core/emails.py", line 39, in send_email
    msg.send()
  File "/home/djangogirls2/.virtualenvs/djangogirls3/lib/python3.7/site-packages/django/core/mail/message.py", line 294, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/djangogirls2/.virtualenvs/djangogirls3/lib/python3.7/site-packages/django/core/mail/message.py", line 248, in get_connection
    self.connection = get_connection(fail_silently=fail_silently)
  File "/home/djangogirls2/.virtualenvs/djangogirls3/lib/python3.7/site-packages/django/core/mail/__init__.py", line 34, in get_connection
    klass = import_string(backend or settings.EMAIL_BACKEND)
  File "/home/djangogirls2/.virtualenvs/djangogirls3/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'djrill'

djrill was a package by Mandrill which is no longer supported for future versions of Django. We therefore need to move to Anymail to enable sending email via Sendgrid etc and fix this error.

amakarudze commented 3 years ago

This error was being caused by a wrong setting for EMAIL_BACKEND in the environment variables. After migrating from Mandrill which used djrill for backend to using Sendgrid, the postactivate file used by the deploy.sh script to set environment variables in production still had this setting

export EMAIL_BACKEND="djrill.mail.backends.djrill.DjrillBackend"

The error was fixed by changing to

export EMAIL_BACKEND="sendgrid_backend.SendgridBackend"

No need to use Anymail since the migration to Sendgrid was done. Only settings files were set incorrectly in the environment variables.

carltongibson commented 3 years ago

Super. That's good work @amakarudze. 👍

amakarudze commented 3 years ago

Thanks @carltongibson!