title: React + NodeJS - nodemailer google cloud functions
body: <p>I am trying to make a reactJS app, and would like to when people ended up filling the form to send some emails. </p>
  
  <p>for that, I have firstly created a sendGrid function but did not like so much the delay and the email templates (and the fact that is more than 100 mails per day.  </p>
  
  <p>then I read that I could use Nodemailer + (or without) express + firebase and google cloud functions. I wrote this function:</p>
  
  <pre><code>exports.mailSun = functions.https.onRequest((req, res) =&gt; {
    const { name, dest } = req.query;
  
    var transporter = nodemailer.createTransport({
      service: 'Gmail',
      host: 'smtp.gmail.com',
      port: 465,
      secure: true,
      auth: {
          user: 'xxx@gmail.com',
          pass: 'xxx'
    }
    });
    const mailOptions = {
      from: 'hello@sunny.com', // sender address
      to: 'pedrospecter@gmail.com', // list of receivers
      subject: 'Elavtal', // Subject line
      html: '&lt;p&gt;Grattis för ditt nya avtal. Elbolag kommer att kontakta dig inom kort.&lt;/p&gt;'// plain text body
    };
  
  return transporter.sendMail(mailOptions, function (err, info) {
    if(err)
      console.log(err)
    else
      console.log(info);
  });
  }); 
  </code></pre>
  
  <p>then I tried </p>
  
  <pre><code>exports.sendMail= functions.https.onRequest((req, res) =&gt; {
  
    cors(req, res, () =&gt; {
  
        // getting dest email by query string
        const { name, dest } = req.query;
        var transporter = nodemailer.createTransport({
          service: 'Gmail',
            host: "smtp.gmail.com",
            port: 465,
            secure: true,
            auth: {
                user: 'xxx@gmail.com',
                pass: 'xxx'
          }
          });
        const mailOptions = {
            from: 'Sunny &lt;xxxb@gmail.com&gt;', // Something like: Jane Doe &lt;janedoe@gmail.com&gt;
            to: 'xxx@mail.com',
            subject: 'nytt Avtal', // email subject
            text: `&lt;p Ni har fått ett nytt avtal. Logga in på Sunny för att se kunddetaljer.&lt;/p&gt; ` // email content in HTML
        };
  
        // returning result
        return transporter.sendMail(mailOptions, (erro, info) =&gt; {
            if(erro){
                return res.send(erro.toString());
            }
            return res.send('Sent');
        });
    });    
  });
  </code></pre>
  
  <p>can someone help me with what is wrong?</p>