title: socket.gaierror: [Errno 11001] getaddrinfo failed in django
body: <p>I am trying to build an ecommerce store with python and django. I am currently building a <code>pay_on_delivery</code> option, and for that, I am sending an email to myself from the email of the user. Here is my <code>OrderForm</code>:</p>
  <pre><code>class OrderForm(forms.Form):
      name = forms.CharField(max_length=30)
      email = forms.EmailField()
      city = forms.CharField(max_length=100)
      address = forms.CharField(widget=forms.Textarea())
      zip_code = forms.CharField(min_length=6,max_length=6)
      product = forms.CharField(max_length=200,widget=forms.TextInput(attrs={'placeholder':'Copy and paste the exact same name of the product you want to purchase'}))
      phone = forms.CharField(min_length=10,max_length=10)
  
      def save(self):
          cleaned_data = self.cleaned_data
          send_mail(
              &quot;Product {cleaned_data['product']} ordered by {cleaned_data['name']}&quot;,
              &quot;A product from our bakery has been ordered. Address: {cleaned_data['address']}. Zip code: {cleaned_data['zip']}. Phone: {cleaned_data['phone']}&quot;,
              cleaned_data[&quot;email&quot;],
              [&quot;rjain1807@gmail.com&quot;],
              fail_silently=False,
          )
  </code></pre>
  <p>And my view function that handles the form submission:</p>
  <pre><code>def buy(request,id):
      product = Product.objects.get(id=id)
      form = OrderForm()
  
      if request.method == 'POST':
          form = OrderForm(data=request.POST)
          if form.is_valid():
              form.save()
              return HttpResponse(&quot;Your order has been successfully placed!!&quot;)
      context = {
          'form':form,
          'product':product,
      }
      return render(request, 'buy_page.html',context)
  </code></pre>
  <p>Now, when I try to place an order, I get this traceback error upon the form submission:</p>
  <pre><code>Internal Server Error: /products/1/buy/
  Traceback (most recent call last):
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\handlers\exception.py&quot;, line 47, in inner
      response = get_response(request)
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\handlers\base.py&quot;, line 179, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\bakery\apnibakeryy\views.py&quot;, line 33, in buy
      form.save()
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\bakery\apnibakeryy\forms.py&quot;, line 20, in save
      fail_silently=False,
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\mail\__init__.py&quot;, line 61, in send_mail
      return mail.send()
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\mail\message.py&quot;, line 284, in send
      return self.get_connection(fail_silently).send_messages([self])
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\mail\backends\smtp.py&quot;, line 102, in send_messages
      new_conn_created = self.open()
    File &quot;C:\Users\Dell\Desktop\Django\apnibakery\venv\lib\site-packages\django\core\mail\backends\smtp.py&quot;, line 62, in open
      self.connection = self.connection_class(self.host, self.port, **connection_params)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\smtplib.py&quot;, line 251, in __init__
      (code, msg) = self.connect(host, port)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\smtplib.py&quot;, line 336, in connect
      self.sock = self._get_socket(host, port, self.timeout)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\smtplib.py&quot;, line 307, in _get_socket
      self.source_address)
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\socket.py&quot;, line 707, in create_connection
      for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    File &quot;C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\socket.py&quot;, line 752, in getaddrinfo
      for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
  socket.gaierror: [Errno 11001] getaddrinfo failed
  </code></pre>
  <p>What is wrong here?</p>