Nodemailer don't work can someone tell me how I can send emails from nodejs server
I use firebase functions and I want the users to send emails from the contact form on my website to my company email, like info@mycompanyemail.com, not Gmail or outlook I generate my email from GoDaddy were I buy my hostname,
I try for 2 days in a row to sent a simple email with nodemailer and I get only errors in my firebase functions LOG
index.js
var functions = require('firebase-functions');
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: 'mail.square-bbbb.gr',
auth: {
user: 'info@square-bbbb.gr',
pass: 'dtranq12!'
},
port : '25',
secure: true, // use SSL
ignoreTLS: true
tls: {
rejectUnauthrized: false
},
});
exports.sendContactMessage = functions.database.ref('/emails/{pushKey}').onWrite(event => {
const snapshot = event.data;
// Only send email for new messages.
if (snapshot.previous.val() || !snapshot.val().name) {
return;
}
const val = snapshot.val();
console.log(val);
const mailOptions = {
from: 'Patric <info@square-bbbb.gr>',
to: 'mail.square-bbbb.gr',
subject: val.message,
text: 'Test tutorial',
// html: val.html
};
console.log(transporter);
console.log(mailOptions);
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
});
And I have only error I have freaked out
The errors on google functions log
Mail {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
options:
{ host: 'mail.square-bbbb.gr',
auth: { user: 'info@square-bbbb.gr', pass: 'pass!' },
port: '25',
secure: true,
tls: { rejectUnauthrized: false },
STARTTLS: true },
_defaults: {},
_defaultPlugins: { compile: [ [Function] ], stream: [] },
_userPlugins: { compile: [], stream: [] },
meta: Map {},
dkim: false,
transporter:
SMTPTransport {
domain: null,
_events: { log: [Function], error: [Function], idle: [Function] },
_eventsCount: 3,
_maxListeners: undefined,
options:
{ host: 'mail.square-bbbb.gr',
auth: [Object],
port: '25',
secure: true,
tls: [Object],
STARTTLS: true },
logger:
{ trace: [Function],
debug: [Function],
info: [Function],
warn: [Function],
error: [Function],
fatal: [Function] },
name: 'SMTP',
version: '4.0.1[client:4.0.1]',
auth:
{ type: 'LOGIN',
user: 'info@square-bbbb.gr',
credentials: [Object],
method: false },
mailer: [Circular] },
logger:
{ trace: [Function],
debug: [Function],
info: [Function],
warn: [Function],
error: [Function],
fatal: [Function] },
close: [Function],
isIdle: [Function],
verify: [Function] }
Other Error
{ Error: getaddrinfo ENOTFOUND mail.square-bbbb.gr mail.square-bbbb.gr:25
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ECONNECTION',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'mail.square-bbbb.gr',
host: 'mail.square-bbbb.gr',
port: '25',
command: 'CONN' }
via George
No comments:
Post a Comment