I am trying to send emails via nodemailer without SMTP transport. So i\'ve done that:
var mail = require(\"nodemailer\").mail;
mail({
from: \"Fred Foo ✔ <
From your example output it seems to connecting to wrong port 25, gmail smtp ports which are opened are 465 for SSL and the other 587 TLS.
Nodemailer detects the correct configuration based on the email domain, in your example you have not set the transporter object so it uses the default port 25 configured. To change the port specify in options the type.
Here's the small example that should work with gmail:
var nodemailer = require('nodemailer');
// Create a SMTP transport object
var transport = nodemailer.createTransport("SMTP", {
service: 'Gmail',
auth: {
user: "test.nodemailer@gmail.com",
pass: "Nodemailer123"
}
});
console.log('SMTP Configured');
// Message object
var message = {
// sender info
from: 'Sender Name ',
// Comma separated list of recipients
to: '"Receiver Name" ',
// Subject of the message
subject: 'Nodemailer is unicode friendly ✔',
// plaintext body
text: 'Hello to myself!',
// HTML body
html:'Hello to myself
'+
'Here\'s a nyan cat for you as an embedded attachment:
'
};
console.log('Sending Mail');
transport.sendMail(message, function(error){
if(error){
console.log('Error occured');
console.log(error.message);
return;
}
console.log('Message sent successfully!');
// if you don't want to use this transport object anymore, uncomment following line
//transport.close(); // close the connection pool
});