Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  26] [ 1]  / answers: 1 / hits: 19258  / 9 Years ago, tue, june 2, 2015, 12:00:00

i'm trying to use the emailjs (https://github.com/eleith/emailjs) for send emails with nodejs, but, it gives me an error: { [Error: timedout while connecting to smtp server] code: 4, smtp: undefined }



I'm trying to use hotmail, but I can use other, I only want this working. Any idea please?



 var email   = require(emailjs);
var server = email.server.connect({
user: [email protected],
password:xxxyyyy,
host: smtp-mail.live.com,
ssl: true
});

// send the message and get a callback with an error or details of the message that was sent
server.send({
text: i hope this works,
from: you <[email protected]>,
to: someone <[email protected]>,
//cc: else <[email protected]>,
subject: testing emailjs
}, function(err, message) { console.log(err || message); });

More From » node.js

 Answers
77

I tested with the code below (using gmail) and it is working:



var email = require('emailjs');

var server = email.server.connect({
user: '[email protected]',
password: 'stackoverflow',
host: 'smtp.gmail.com',
ssl: true
});

server.send({
text: 'Hey howdy',
from: 'NodeJS',
to: 'Wilson <[email protected]>',
cc: '',
subject: 'Greetings'
}, function (err, message) {
console.log(err || message);
});


In my console the output is:



{ 
attachments: [],
alternative: null,
header: {
'message-id': '<[email protected]>',
date: 'Tue, 02 Jun 2015 10:48:58 -0400',
from: '=?UTF-8?Q?NodeJS?= <>',
to: '=?UTF-8?Q?Wilson?= <[email protected]>',
cc: '',
subject: '=?UTF-8?Q?Greetings?='
},
content: 'text/plain; charset=utf-8',
text: 'Hey howdy'
}


Indeed I have received in my inbox the email message.



I suspect that you should use the host smtp.live.com instead of smtp-mail.live.com



Note: The account ([email protected]) used is a valid one I just created for testing purposes.


[#66369] Sunday, May 31, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryanulyssesb

Total Points: 91
Total Questions: 105
Total Answers: 102

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
ryanulyssesb questions
Sat, Mar 20, 21, 00:00, 3 Years ago
Mon, Sep 14, 20, 00:00, 4 Years ago
Mon, Mar 9, 20, 00:00, 4 Years ago
Sun, Jul 7, 19, 00:00, 5 Years ago
;