I am now using Django as the backend API endpoints and I want to send out email to for notification.
settings.py
#Email settings
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'test.'
EMAIL_HOST_USER = 'test@gmail.com'
EMAIL_PORT = 587
views.py
def GetEmailNotification(request):
subject = "This is a test email"
message = "This is a test message"
from_email = 'test@gmail.com'
send_mail(subject, message, from_email, ['test@gmail.com'], fail_silently=False)
return HttpResponse("sent!")
urls.py
urlpatterns = [path('emailNotification/', GetEmailNotification)]
But when I did the get request. it gave the error
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
After I changed the port in the setting.py from 457 to 1000, it gave the error of
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
How to solve this issue? Any ideas?