Reputation: 4606
I am trying to use mailjs to send out email, and here is what I got:
var server = email.server.connect({
user: "[email protected]",
password: "pw",
host: "smtp.office365.com",
port: "587",
tls: true
});
server.send({
text: "test!!",
from: "[email protected]",
to: "[email protected]",
subject: "hello"
}, function(err, message){console.log(err || message);});
The above code eventually throw me an error:
{ [Error: authorization.failed]
code: 3,
previous: { [Error: timedout while connecting to smtp server] code: 4, smtp: undefined },
smtp: undefined }
So basically my corporate email service is on office365, configured to use mydomain.com. I don't really know what does the user and password mean for the server, so I just used the sender's email and password. Is it anything wrong with my code? Maybe this is the problem?? Or otherwise what would it be?
Upvotes: 3
Views: 3316
Reputation: 640
First check and confirm host.Here is no need to use port: "587", tls: true. You can use, this is wrking code
var server = email.server.connect({
user: '[email protected]',
password: 'vvq3tng$',
host: 'your host',
ssl: true,
});
server.send({
from: '<[email protected]>', // sender address
to: '<[email protected]>',// list of receivers
cc: '',
subject: 'your subject', // Subject line
text: 'contant', // html body
}, function (err, message) {
if(err) {
console.log(err)
} else {
console.log("email sent")
}
});
Upvotes: 1