Error:SMTPSenderRefused at /register

Im new to Django and im trying to send an email to user
i put this in settings.py : EMAIL_HOST=‘smtp.gmail.com
EMAIL_HOST_USER=‘
EMAIL_HOST_PASSSWORD='

EMAIL_PORT= 587
EMAIL_USE_TLS= True
EMAIL_BACKEND= ‘django.core.mail.backends.smtp.EmailBackend’
ALLOWED_HOSTS =
and this in views.py in def register :
send_mail(
‘Contact Form’,
‘Bienvenueeeee a toi’,
‘settings.EMAIL_HOST_USER’,
[email],
fail_silently=True)
Error:SMTPSenderRefused at /register

Many possibilities here.

  • Your email host user isn’t correct
  • Your email host password isn’t correct
  • Your email account doesn’t have “Less secure apps” enabled
  • You’re not using an app password for your account
  • The email address you’re using as the “from” address isn’t authorized for that account.

I suggest you find a blog post that describes exactly what needs to be done to send emails through gmail using smtp.

What I also suggest you do is write a small-standalone script to use the Python SMTP library to send a test email from the command line. Use that to check your account’s settings and server configuration before setting it up in Django.