Home > front end >  Sending email from DebuggingServer localhost:1025 not working
Sending email from DebuggingServer localhost:1025 not working

Time:12-06

Im testing sending an email after filling out a form on a website and im using my local host. Upon submitting the form I'm using the django send_mail() method and Im sending the test email to a gmail account and I have the account as a list data type.

$ python -m smtpd -n -c DebuggingServer localhost:1025

And I'm getting this depreciated message after I turn on the server and I also have yet to receive an email from my local host

C:\Users...\AppData\Local\Programs\Python\Python310\lib\smtpd.py:104: DeprecationWarning: The asyncore module is deprecated. The recommended replacement is asyncio import asyncore C:\Users...\AppData\Local\Programs\Python\Python310\lib\smtpd.py:105: DeprecationWarning: The asynchat module is deprecated. The recommended replacement is asyncio import asynchat

Here's whats in my settings.py file:

EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False

Any ideas why its not sending?

CodePudding user response:

I couldn't Completely get it but it seems like its asking for asynchronous task scheduler like celery with rabbitmq or radis.

more over this is the warning. I am not sure but you can pass this by changing your settings.py

DEBUG = True

to this

 DEBUG = False

may this work.

more in your settings.py

EMAIL_HOST = 'localhost'

seems fishy, you should use

 EMAIL_HOST = 'smtp.gmail.com'

CodePudding user response:

First of all, you must configure your email to access your project. Use the following link to send a debt email: https://dev.to/abderrahmanemustapha/how-to-send-email-with-django-and-gmail-in-production-the-right-way-24ab

#settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'key' #past the key or password app here
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'default from email'

Sign in to gmail and then click Manage your google account then enter the security section from the page that opens, like this: enter image description here

you have to type your password again

and

click on select app choose *** other (Custome Name) *** and give a name to you app

the last step click on generate and Gmail will generate a key or an app password make sure to copy this key or save it in a text file

and use for EMAIL_HOST_PASSWORD

  • Related