(421, b'Service not available')

Viewed 16

I have a simple method (send_activation_email) called from a view which handles user registration by extending default django user auth. It sends an activation email. Now I get the error:

Please help me out guys

    Exception Type: SMTPConnectError
    Exception Value:    
    (421, b'Service not available') 

The Method Implementation

    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 Configuration in Settings

    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'. 

Call the function in view

    send_verification_email(request, user) 

Template

    {% autoescape off %}
    Hi {{user.first_name}},
    Please click on below link to verify your email
    http://{{domain}}{% url 'activate' uidb64=uid token=token %}
    {% endautoescape %}. 
0 Answers
Related