title: Get Error 530 5.7.0 Authentication Required when sending email using Django Python
body: <p>I am trying to send emails with G-Suite account using python in Django. As Google stoped the less secure App option for the new applications, I have to use Oauth2. 
  But when I start to send emails via smtplib, the ERROR:</p>
  
  <pre><code>smtplib.SMTPSenderRefused: (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0  https://support.google.com/mail/?p=WantAuthError q4sm8418287pfl.175 - gsmtp'
  </code></pre>
  
  <p>And after looking up the reference, it means "530, "5.7.0", Must issue a STARTTLS command first."
  However, I have added "server.starttls()". Could someone help me? Many thanks.</p>
  
  <pre><code>server = smtplib.SMTP('smtp.gmail.com', port=587)
  server.ehlo('test')
  server.starttls()
  server.docmd('AUTH', 'XOAUTH2 ' + base64.b64encode(auth_string.encode()).decode("utf-8"))
  server.sendmail(from_addr, to_addr, msg.as_string())
  server.quit()
  </code></pre>