-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot send emails #12678
Comments
did you try to wrap the username/password in the double quotes? |
Already did with # EMAIL Notifications
EMAIL_ENABLE=True
DJANGO_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
DJANGO_EMAIL_HOST=smtp.gmail.com
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER="[email protected]"
DJANGO_EMAIL_HOST_PASSWORD="password_edited"
DJANGO_EMAIL_USE_TLS=True
DJANGO_EMAIL_USE_SSL=False
DEFAULT_FROM_EMAIL='Soporte <[email protected]>' # eg Company <[email protected]> |
Here, If a test sending an email with same credentials with the following python script it works fine: import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('[email protected]', 'password_edited')
server.sendmail('[email protected]', '[email protected]', 'Subject: Test Email\n\nThis is a test email.')
server.quit()
print('Test email sent!') But as said earlier it does not work with Geonode. For example, if I try: docker exec -it django4my_geonode python manage.py shell -c "from django.core.mail import send_mail; send_mail('TEST GEONODE EMAIL', 'Test Message', '[email protected]', ['[email protected]'], fail_silently=False)" I get the following output error: Traceback (most recent call last):
File "/usr/src/my_geonode/manage.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/commands/shell.py", line 117, in handle
exec(options["command"], globals())
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/django/core/mail/__init__.py", line 87, in send_mail
return mail.send()
File "/usr/local/lib/python3.10/dist-packages/django/core/mail/message.py", line 298, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 127, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 94, in open
self.connection.login(self.username, self.password)
File "/usr/lib/python3.10/smtplib.py", line 750, in login
raise last_exception
File "/usr/lib/python3.10/smtplib.py", line 739, in login
(code, resp) = self.auth(
File "/usr/lib/python3.10/smtplib.py", line 662, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. For more information, go to\n5.7.8 https://support.google.com/mail/?p=BadCredentials 2adb3069b0e04-53c7bc9c966sm1556331e87.111 - gsmtp') My question is why? Is the same email and credentials. This is driving me crazy :( I've checked the env variables inside the container just to make sure, and they exists with correct values. |
I guess that Django Email is considered by Google as less secure application (LSA). Google has trying to phase out such logins since 2019 and this is still ongoing. However, if you are trying to configure simple username and password you should consider creating an app password and use this instead. |
I will try it and report back. |
Expected Behavior
Allow to send user invitations via email
Actual Behavior
Every time I try I get this error
add_message() argument must be an HttpRequest object, not 'NoneType'. (<class 'TypeError'>)
Steps to Reproduce the Problem
.env
with email credentialsSpecifications
The text was updated successfully, but these errors were encountered: