const nodeMailer = require("nodemailer");
const sendEmail = async (options) => {
const transporter = nodeMailer.createTransport({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
secure: true,
service: process.env.SMTP_SERVICE,
auth: {
type: 'OAuth2',
user: process.env.SMTP_MAIL,
pass: process.env.SMTP_PASSWORD,
},
});
const mailOptions = {
from: process.env.SMPT_MAIL,
to: options.email,
subject: options.subject,
text: options.message,
};
await transporter.sendMail(mailOptions,function(err,info){
if(err){
console.log(err)
} else {
console.log('success')
}
});
};
module.exports = sendEmail;
when i process this it says "Can't create new access token for user" can anyone help reg this? in env files host is "smtp.gmail.com" and port no is 465 , smtp_service is gmail.
i have read some docs regarding gmail api where you require client Id,access token, refresh token but was confused if naming convection is correctly defined or not or if gmail api naming convection is different?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment