title: What's the difference between TLS and SSL in smtplib Python
body: <p>We have written a program in Python, where we are sending a mail to our private gmail account. We can use either SSL or TLS but we're in doubt in which is the most secure protocol to use. </p>
  
  <p>This is our code: </p>
  
  <pre><code>def send_mail(subject, msg):
      try:
  #       server = smtplib.SMTP('smtp.gmail.com:587') # TLS (DOES NOT WORK WITH SSL)
          server = smtplib.SMTP_SSL('smtp.gmail.com:465')
          server.ehlo()
  #       server.starttls() #TLS (DOES NOT WORK WITH SSL)
          server.login(config.EMAIL_ADDRESS, config.PASSWORD)
          message = 'Subject: {}\n\n{}'.format(subject, msg)
          server.sendmail(config.EMAIL_ADDRESS, config.SEND_EMAIL, message)
          server.quit()
          print ("Successfully sent email")
      except SMTPException:
          print ("Error: unable to send email")
  </code></pre>
  
  <p>What we want to know is what is the most secure to use for smtp? TLS or SSL? </p>