(421, b'Service not available')
У меня есть простой метод (send_activation_email), вызываемый из представления, которое обрабатывает регистрацию пользователя, расширяя стандартный django user auth. Он отправляет письмо с активацией. Теперь я получаю ошибку:
Пожалуйста, помогите мне, ребята
Exception Type: SMTPConnectError
Exception Value:
(421, b'Service not available')
Реализация метода
def send_activation_email(user, request):
current_site = get_current_site(request)
subject = 'Activate your membership Account'
message = render_to_string('accounts/account_activation_email.html',{
'user': user,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': account_activation_token.make_token(user),
})
html_message = get_template('accounts/account_activation_html_email.html').render({
'user': user,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': account_activation_token.make_token(user),
})
send_mail(subject=subject,
message=message,
from_email= None,
recipient_list=[user.email],
html_message= html_message
#,fail_silently=False
)
Конфигурация электронной почты в Настройках
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'asoliu34@gmail.com'
EMAIL_HOST_PASSWORD = 'syxkgrfbczefd' #past the key or password app here
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'default from email'.
Вызвать функцию в представлении
send_verification_email(request, user)
Шаблон
{% autoescape off %}
Hi {{user.first_name}},
Please click on below link to verify your email
http://{{domain}}{% url 'activate' uidb64=uid token=token %}
{% endautoescape %}.