Я пытаюсь создать модуль, который позволяет мне отправлять пользователям электронные письма.
Однако я сталкиваюсь с ошибкой:
TimeoutError at / email
[Errno 60] Тайм-аут операции
urls.py
from django.contrib import admin
from django.conf.urls import url
from emailfunction.views import send_email
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^email', send_email),
]
views.py
from django.http import HttpResponse
from django.conf import settings
from django.core.mail import send_mail
def send_email(request):
subject = 'Test Subject'
message = 'Test Message./n 123 123 456 456 778 990./n From ABC/n'
from_email = settings.EMAIL_HOST_USER
to_list = ['receiver@gmail.com', settings.EMAIL_HOST_USER]
send_mail(subject, message, from_email, to_list, fail_silently=False)
return HttpResponse("Mail has been sent. Please check your mail. Thank YOU!")
Соответствующие данные из settings.py
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'sender@gmail.com'
EMAIL_HOST_PASSWORD = '**************'
EMAIL_PORT = 587