Сейчас я использую Django в качестве конечных точек бэкэнд-API и хочу отправить электронное письмо на уведомление.
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)]
Но когда я сделал запрос get.он выдал ошибку
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
После того, как я изменил порт в setting.py с 457 на 1000, он выдал ошибку
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.
Как решить эту проблему?Есть идеи?