title: sending email from python 3.4 script, WITHOUT enabling 'less secure apps' in gmail
body: <p>I would like to send mail using a python 3.4 script, from my gmail address.
  I use the following code:</p>
  <pre class="lang-py prettyprint-override"><code>import smtplib  
  
  def sendmail():  
      sender='myemail@gmail.com'  
      receiver=['someone@gmail.com']  
      message='text here'  
      try:  
          session=smtplib.SMTP('smtp.gmail.com',587)  
          session.ehlo()  
          session.starttls()  
          session.ehlo()  
          session.login(sender,'mypassword')  
          session.sendmail(sender,receiver,message)  
          session.quit()  
      except smtplib.SMTPException:  
          print('Error, can not send mail!')
  </code></pre>
  <p>If I 'allow less secure apps' in my gmail account, the script works fine. However, if I disable 'less secure apps', it doesn't work (I get a warning email from google, with 'sign-in attempt blocked') . I would like to modify my code, to be able to send mail without enabling this thing.</p>
  <p>I have read all the questions and answers regarding similar problems, but did not find any useful answers or methods. Does someone have a solution for this?</p>