Using Thunderbird From Node.js & nodemailer package . . .
I am trying to use one of my Thunderbird email accounts as the one that sends authentication emails to new website registrants. Below is the function being trialed for this but with a Gmail account. Using a Gmail account for this purpose is no longer possible as accessing one's Gmail via a third-party program is not allowed since June 2022. My biggest problem is what entry I should apply for my mail service when: 1) Testing the web app locally and using Thunderbird as the "sender" of confirmation emails; and 2) Testing the app on the web server where I propose to use one of the website owner's email accounts for this task.
/** Sends a registration confirmation ID to the user.
* @param {String} email - the email address of the user registering * */
const sendConfirmEmail = (email) => { const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'bozomailbox@gmail.com', pass: '***********' } });
console.log("Confirmation email: " + email); confirmid = sha256(email); const mailOptions = { from: 'bozomailbox@gmail.com', to: email, subject: 'Register On NodeApp', text: 'Dear ' + user + ',' + '\n\nPlease confirm your registration by clicking on the link below:' + '\n\nlocalhost:3000/reg-confirm?user=' + user + '&confirmid=' + confirmid + '\n\nHave A Nice Day,' + '\n\n All At NodeApp !' };
transporter.sendMail(mailOptions, (error, info) => { if(error) { return console.log(error); } console.log('Message sent: ' + info.response); });
};
Okulungisiwe