I am trying to send a mail using Firebase Functions from an onCreate trigger using nodemailer and Zoho mail account. This is the entire function
export const mailFunc = functions.database.ref('/data/{messageId}')
.onCreate((snapshot, context) => {
const data = snapshot.val();
const transporter = nodemailer.createTransport({
service: "Zoho",
auth: {
user: 'name@mydomain.in',
pass: 'passwordgoeshere'
}
});
const mailOptions: nodemailer.SendMailOptions = {
from: 'name@mydomain.in',
to: 'someone@gmail.com',
subject: 'Here goes the subject',
text: `${data.message}\n\n${data.name}`
};
return transporter.sendMail(mailOptions)
});
The thing is when I run this function with an invalid username or password it gives Error: Invalid login
and when I try it with the correct username and password it gives the below error log
Error: getaddrinfo ENOTFOUND smtp.zoho.com
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
For reference
- Using Firebase free plan (Spark Plan)
- Haven't connected the custom domain yet
- Using Zoho Free Plan
- The password contains special characters(it's mandatory in Zoho)
- Haven't changed any settings in the Zoho account other than the initial setup(Mail is working properly)
I am just getting started with Firebase and Node. I think the reference points may help. I am really stuck please help.