title: Sending email with python smtplib not working, confused about the "from" field
body: <p>I'm trying to send an email in python. Here is my code.</p>
  
  <pre><code>import smtplib
  
  if __name__ == '__main__':
  SERVER = "localhost"
  
  FROM = "sender@example.com"
  TO = ["wmh1993@gmail.com"] # must be a list
  
  SUBJECT = "Hello!"
  
  TEXT = "This message was sent with Python's smtplib."
  
  # Prepare actual message
  
  message = """\
  From: %s
  To: %s
  Subject: %s
  
  %s
  """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
  
  # Send the mail
  
  server = smtplib.SMTP(SERVER)
  server.sendmail(FROM, TO[0], message)
  server.quit()
  print "Message sent!"
  </code></pre>
  
  <p>This runs without error, but no email is sent to <code>wmh1993@gmail.com</code>. </p>
  
  <p><strong>Questions</strong> </p>
  
  <p>One thing I don't understand about this code --- what restrictions do I have when setting the <code>FROM</code> field? </p>
  
  <p>Do I somehow have to say that it was from my computer? </p>
  
  <p>What is in place to prevent me from spoofing someone else's email? </p>
  
  <p>Or am I at liberty to do that?</p>