title: Having trouble with sending an email through SMTP Python
body: <p>So I'm trying to send an email through SMTPlib with Python, but I can't get it to work. I read up on the Microsoft SMTP specs, and put them in accordingly, but I can't get it to work. Here is my code:</p>
  
  <pre><code>    # Send an email
      SERVER  = "smtp-mail.outlook.com"
      PORT    = 587
      USER    = "******@outlook.com"
      PASS    = "myPassWouldBeHere"
      FROM    = USER
      TO      = ["******@gmail.com"]
      SUBJECT = "Test"
      MESSAGE = "Test"
      message = """\
  From: %s
  To: %s
  Subject: %s
  %s
  """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
      try:
          server = smtplib.SMTP()
          server.connect(SERVER, PORT)
          server.starttls()
          server.login(USER,PASS)
          server.sendmail(FROM, TO, message)
          server.quit()
      except Exception as e:
          print e
          print "\nCouldn't connect."
  </code></pre>
  
  <p>I got the code from a keylogger, but I cleaned it up a bit. I read up <a href="http://www.tutorialspoint.com/python/python_sending_email.htm" rel="noreferrer">here</a> on how basic SMTP works, but there are few things like <code>starttls</code> (Methods) I don't quite understand.</p>
  
  <p>I really appreciate any help with this.</p>