How do I send email from my Gmail account in my Node.js script?

app.get('/email', function(req,res){
    var emailjs = require('emailjs');
    var email_server = emailjs.server.connect({
        host: 'smtp.gmail.com',
        ssl: true,
        tls: true,
        port: "465",
        user:'kateholloway@gmail.com',
        password:'mypassword',
    });

    var h={
        text: 'hey how you doing',
        from: 'Kate Holloway <kateholloway@gmail.com>',
        to: 'someonesemail@gmail.com',
        subject: 'where is your phone'
    };
    var message = emailjs.message.create(h);
    email_server.send(message, function(err,message){
        console.log(err);
        console.log(message);
        res.send('ok');
    });

});

Is this the right settings to do it?

The error message I get is:

{ [Error: connection has ended] code: 9, smtp: undefined }

Note: this code works with my own domain/server. But it doesn't work with Gmail. Therefore, I think my settings for Gmail smtp are incorrect.

We have used this library with Gmail. We have only set host, user, password and ssl options. Its working as expected. Try removing other options.