-3

I want to create a signup form that sends an activation key to user. This sent email shows a log-in activation link to continue to create a account. Now what i did is that i wrote these lines in my settings.py file to sent email.

ACCOUNT_ACTIVATION_DAYS=7
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'emailaddress@gamil.com'

but this is not working well or may be the way i am using this is wrong. I need your help to solve this problem. Thanks.

Tameen Malik
  • 1,258
  • 6
  • 17
  • 45

2 Answers2

3

You can try this settings in your setting.py.

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER='your gmail user name'
EMAIL_HOST_PASSWORD='your gmail password'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = True

Test Email configuration : in your command line :

$ python manage.py shell

from django.core.mail import send_mail
send_mail("testing", "Did this work?", "no-reply@abc.net", ["email where you want to send ", ], fail_silently=False)
Yogesh dwivedi Geitpl
  • 4,252
  • 2
  • 20
  • 34
2

This hast nothing to to with Django or Python, you're Gmail details are misconfigured

EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''

Above needs to be set to your Gmail user (email) and password

EMAIL_USE_TLS = False
EMAIL_PORT = 587

TLS is required, it needs to be set to True. In consequence port has to be set to SMTP over SSL, which is 465

vartec
  • 131,205
  • 36
  • 218
  • 244