0

ConnectionRefusedError at /contact/ [WinError 10061] No connection could be made because the target machine actively refused it

Program are running normally when i open this page this error are Seenenter image description here

{% csrf_token %}
        <div class="row" >
            <div class="col" style="margin-top: 50px;">
                <input type="text" class="form-control" placeholder="First name" style="height: 50px;" name="fistname">
            </div>
            <div class="col"style="margin-top: 50px;">
              <input type="text" class="form-control" placeholder="Last name" style="height: 50px;" name="lastname"">
            </div>
        </div>

        <div class="form-group"style="margin-top: 50px;">
            
            <input type="email" class="form-control"id="exampleFormControlInput1" placeholder="Enter Your Mail id " style="height: 50px;" name="email" >
        </div>
        <div class="form-group" style="margin-top: 50px;">
            <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Please enter Your Messages here" style="height: 200px;" name="msg"></textarea>
        </div>
        <div class="text-center">
            <button type="submit" class="btn btn-secondary btn-lg" style="margin-top: 50px;">Send Now</button>
        </div>
    </form>
view.py
def contact(request):
    if request.method == "POST":
        firstname = request.POST['firstname']
        lastname = request.POST['lastname']
        email = request.POST['email']
        msg = request.POST['msg']
    send_mail(
            'Please check it',
            'msg',
            'settings.EMAIL_HOST_USER',
            ['email'],
            fail_silently=False,
        )

    return render(request,'core/contact.html')

setting.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "smtp.gmail.com "
EMAIL_PORT = 587
EMAIL_HOST_USER = "absc@gmail.com"
EMAIL_HOST_PASSWORD ="kiubgwnoo"
EMAIL_USE_TLS = True 
  • Hi, welcome to Stack Overflow! Don't post error as images, include it inside the question. Include code in question, in this case probably your email-related settings variables. – NixonSparrow Aug 27 '22 at 15:00

1 Answers1

0

Try to put your sendmail() function inside the if-statement.

Timus
  • 10,974
  • 5
  • 14
  • 28