title: Python: when sending email, always blocked in the clause: smtpserver = smtplib.SMTP("smtp.gmail.com",587)
body: <p>I am writing a Python program to send an email. But every time when executing the clause:</p>
  
  <pre><code>smtpserver = smtplib.SMTP("smtp.gmail.com",587)
  </code></pre>
  
  <p>it will block here and always stay the executing status without any prompts and errors. I don't know why. And can anyone help me?</p>
  
  <p>The code is as following:
      import smtplib</p>
  
  <pre><code>to = 'toemail@gmail.com'
  gmail_user = 'user@gmail.com'
  gmail_pwd = 'password'
  smtpserver = smtplib.SMTP("smtp.gmail.com",587)
  smtpserver.ehlo()
  smtpserver.starttls()
  smtpserver.ehlo
  smtpserver.login(gmail_user, gmail_pwd)
  header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
  print header
  msg = header + '\n this is test msg from mkyong.com \n\n'
  smtpserver.sendmail(gmail_user, to, msg)
  print 'done!'
  smtpserver.close()
  </code></pre>