email authentication python

import smtplib

server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login("your username", "your password")
server.sendmail(
  "from@address.com", 
  "to@address.com", 
  "this message is from python")
server.quit()

Here is what the above code is Doing:
1. Create an SMTP object.
2. Log in to the server.
3. Send the mail.
4. Disconnect from the server.