title: Python SMTP socket.gaierror: [Errorno -2] Name or Service not found
body: <p>I am using SMTP connection to connect and send email but I get SMTP socket.gaierror: [Errorno -2] Name or Service not found. here is my code</p>
  
  <pre><code>from smtplib import SMTP
  import datetime
  
  debuglevel = 0
  
  smtp = SMTP()
  smtp.set_debuglevel(debuglevel)
  smtp.connect('MY.MAIL.SERVER', 587)
  smtp.login('USERNAME@DOMAIN', 'PASSWORD')
  
  from_addr = "ann@abcsystems.com"
  to_addr = "minna@abcsystems.com"
  
  subj = "hello"
  
  message_text = "Hello\nThis is a test mail from server\n\n"
  
  msg = "From: %s\nTo: %s\nSubject: %s\n\n%s" 
          % ( from_addr, to_addr, subj, message_text )
  
  smtp.sendmail(from_addr, to_addr, msg)
  smtp.quit()
  </code></pre>