title: Email is not being sent via python
body: <p>I have created this piece of code as a test run to send an email over python:</p>
  <pre><code>import smtplib
  import random
  import math
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  ADMIN_EMAIL = email
  ADMIN_PASS = password
  
  
  
  def generate_ver_code():
      digs = &quot;0123456789&quot;
      code = &quot;&quot;
      for i in range(0, 6):
          code += digs[math.floor(random.random() * 10)]
      return code
  
  
  
  def signup(forename, surname, email, occupation, dob, pass1, pass2, pass_match):
      ran_num = str(random.randint(0, 9999))
      if len(ran_num) &gt;= 4:
          if len(ran_num) == 1:
              ran_num = &quot;000&quot; + str(ran_num)
          elif len(ran_num) == 2:
              ran_num = &quot;00&quot; + str(ran_num)
          elif len(ran_num) == 3:
              ran_num = &quot;0&quot; + str(ran_num)
          elif len(ran_num) == 4:
              ver_code = str(ran_num)
      username = ran_num + forename[:3] + surname[:3] + dob[:2]
      
      if pass1 == pass2:
          passw = pass1
          pass_match = True
      else:
          pass_match = False
      s = smtplib.SMTP('smtp.gmail.com', 5354)
      #home port = 5354
      #school port = 
      s.starttls()
      s.login(ADMIN_EMAIL, ADMIN_PASS)
      msg = MIMEMultipart()
      message = message_template.substitute(PERSON_NAME=forename)
      msg['From']=ADMIN_EMAIL
      msg['To']=email
      msg['Subject']=&quot;Verify account: FAKtory Reset&quot;
      msg.attach(MIMEText(message, '\nBefore you can continue to use your account please verify yur account and check if the credentials are correct:\nUsername: '+ username + '\nName: ' + forename + ' ' + surname + '\nOccupation: ' + occupation + '\nDoB: ' + dob + '\nPassword: ' + pass1 + '\nVerification Code: ' + ver_code + '\nIf any of the credentials are wrong please enter them again on our app.\nThank you,\nRegards,\nFaizan Ali Khan\nAdmin'))
      s.send_message(msg)
      del msg
  
  
  
  pass_match = False
  forename = str(input(&quot;Enter your forename: &quot;))
  surname = str(input(&quot;Enter your surname: &quot;))
  email = str(input(&quot;Enter your email: &quot;))
  occupation = str(input(&quot;Enter your occupation: &quot;))
  dob = str(input(&quot;Enter your date of birth (DD/MM/YYYY): &quot;))
  pass1 = str(input(&quot;Enter your password: &quot;))
  pass2 = str(input(&quot;Enter your password again: &quot;))
  print(signup(forename, surname, email, occupation, dob, pass1, pass2, pass_match))
  </code></pre>
  <p>Now whenever I run the code it goes fine for the inputs but when it comes to sending the email I get this error:</p>
  <pre><code>TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  </code></pre>
  <p>How would you fix this error? I tried changing the port but still it doesn't work.</p>