title: Python Email, [Errno 10061] No connection could be made because the target machine actively refused it
body: <p>I want to send a mail in using python, below is my code, but I got the error 10061 at the end, hope anyone can help me, thanks!</p>
  
  <pre><code>import smtplib
  fromaddr = 'XXX@XX.com'
  toaddrs  = 'XXX@XX.com    '
  msg = 'Why,Oh why!'
  username = 'XXXXXX'
  password = 'XXXXXX'
  server = smtplib.SMTP('smtp.gmail.com:587')
  server.ehlo()
  server.starttls()
  server.login(username,password)
  server.sendmail(fromaddr, toaddrs, msg)
  server.quit()
  </code></pre>
  
  <p>error msg:socket.error: [Errno 10061] No connection could be made because the target machine actively refused it</p>