title: smtp error: 534 when sending email through gmail in golang app
body: <p>On my golang app I use <a href="https://gist.github.com/jpillora/cb46d183eca0710d909a" rel="nofollow noreferrer">this</a> snippet to send email from my gmail account:</p>
  
  <pre><code>func send(body string) {
      from := "myaccount@gmail.com"
      pass := "mysupersecretpasswd"
      to := "whoever@whatever.com"
  
      msg := "From: " + from + "\n" +
          "To: " + to + "\n" +
          "Subject: Hello there\n\n" +
          body
  
      err := smtp.SendMail("smtp.gmail.com:587",
          smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
          from, []string{to}, []byte(msg))
  
      if err != nil {
          log.Printf("smtp error: %s", err)
          return
      }
  
      log.Print("sent, visit whatever)
  }
  </code></pre>
  
  <p>I get this error instead:</p>
  
  <pre><code>smtp error: 534 5.7.14 &lt;https://accounts.google.com/signin/continue?sarp=1&amp;scc=1&amp;plt=AKgnsbud
  5.7.14 lxVDnr-tXOckmxXi0fxExY5BKDRczBpGvMCpGWGF97jAI5DlM2oeGMDcIkvBhKT9rJAVnH
  5.7.14 WP7zxssynLtkzMb35et-wxJF2AfeBhMA81QqMh2F8fkQRdf9GidA3swFnjfsUl0Pw6fiMT
  5.7.14 b3zvEJyD6WAKEWcuxEGJIBTaqCtfDjipQ58cFJweUiKg1_4AJp0fGpC9ufnjBGWqWVKeW9
  5.7.14 QVbUstROYK0SzjWXTTvsvZhhG3RjM&gt; Please log in via your web browser and
  5.7.14 then try again.
  5.7.14  Learn more at
  5.7.14  https://support.google.com/mail/answer/78754 61sm6182123wre.44 - gsmtp
  </code></pre>
  
  <p>I have installed postfix on my localhost. I have also allowed less secure apps to access my account. 
  I have also tried the same code on my VPS, but it does not send emails either.</p>
  
  <p>So what could be wrong? How can I fix it?</p>