Reputation: 271704
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:'[email protected]',
password:'mypassword',
});
var h={
text: 'hey how you doing',
from: 'Kate Holloway <[email protected]>',
to: '[email protected]',
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.
Upvotes: 2
Views: 1786
Reputation: 261
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.
Upvotes: 1