title: Accessing gmail API on front-end angular app
body: <p>Trying to figure out how to get access to googles API so I can create a contact form on my website, I have found this example but am struggling to use / convert it for use in Angular.</p>
  
  <p><a href="https://github.com/googleapis/google-api-nodejs-client/blob/master/samples/gmail/send.js" rel="nofollow noreferrer">https://github.com/googleapis/google-api-nodejs-client/blob/master/samples/gmail/send.js</a></p>
  
  <p>I have just done <code>npm install googleapis</code> but am unsure about how to continue. I know this is strictly speaking not a programming question, but I am wondering if anyone can help set up a mailing (contact form) for my portfolio. This is also my first time working with an API and I am doing a fair amount of research to figure out how to correctly do everything.</p>
  
  <p>I am trying to go throught the documentation on the google API but as it is auto generated, the interface is a bit questionable... <a href="https://googleapis.dev/nodejs/googleapis/latest/index.html" rel="nofollow noreferrer">https://googleapis.dev/nodejs/googleapis/latest/index.html</a> and I can't really find any useful information on it...</p>
  
  <p>What i want to make is a way for people to contact me, so I send an e-mail to my work mail adress with their mail address attached so I can reply, a subject and a body. This is all the information I would need but as the API is very unclear I am having a hard time figuring out hhow to do this in Angular (Node.js)</p>
  
  <p>TL;DR: How to connect Angular 8 (Node.js) to gmail api (or use smtp)</p>
  
  <p>UPDATE: I changed to using nodemailer for the smtp but it isnt working still</p>
  
  <pre class="lang-js prettyprint-override"><code>import * as mailer from 'nodemailer';
  
  export class Mailing {
      constructor() {
          this.send();
      }
  
      async send() {
          const account = await mailer.createTestAccount();
          const transporter = mailer.createTransport({
              host: 'smtp.gmail.com',
              port: 587,
              secure: false,
              auth: {
                  user: account.user,
                  pass: account.pass
              }
          });
  
          const info = await transporter.sendMail({
              from: '"Portfolio" &lt;Portfolio@gmail.com&gt;',
              to: 'torbenvanassche.dev@gmail.com',
              subject: 'Hello',
              text: 'shut up',
          });
      }
  }
  </code></pre>
  
  <pre><code>ERROR in ./node_modules/nodemailer/lib/sendmail-transport/index.js
  Module not found: Error: Can't resolve 'child_process' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\sendmail-transport'
  ERROR in ./node_modules/nodemailer/lib/mailer/index.js
  Module not found: Error: Can't resolve 'dns' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\mailer'
  ERROR in ./node_modules/nodemailer/lib/shared/index.js
  Module not found: Error: Can't resolve 'dns' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\shared'
  ERROR in ./node_modules/nodemailer/lib/dkim/index.js
  Module not found: Error: Can't resolve 'fs' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\dkim'
  ERROR in ./node_modules/nodemailer/lib/mime-node/index.js
  Module not found: Error: Can't resolve 'fs' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\mime-node'
  ERROR in ./node_modules/nodemailer/lib/shared/index.js
  Module not found: Error: Can't resolve 'fs' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\shared'
  ERROR in ./node_modules/nodemailer/lib/mailer/index.js
  Module not found: Error: Can't resolve 'net' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\mailer'
  ERROR in ./node_modules/nodemailer/lib/shared/index.js
  Module not found: Error: Can't resolve 'net' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\shared'
  ERROR in ./node_modules/nodemailer/lib/smtp-connection/index.js
  Module not found: Error: Can't resolve 'net' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\smtp-connection'
  ERROR in ./node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js
  Module not found: Error: Can't resolve 'net' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\smtp-connection'
  ERROR in ./node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js
  Module not found: Error: Can't resolve 'tls' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\smtp-connection'
  ERROR in ./node_modules/nodemailer/lib/smtp-connection/index.js
  Module not found: Error: Can't resolve 'tls' in 'C:\Users\tassc\Projects\Portfolio\node_modules\nodemailer\lib\smtp-connection'
  </code></pre>
  
  <p>UPDATE: Interesting article about using the google API in Angular <a href="https://blog.angularindepth.com/google-apis-with-angular-214fadb8fbc5" rel="nofollow noreferrer">https://blog.angularindepth.com/google-apis-with-angular-214fadb8fbc5</a></p>