Helo , im have this problem with node mailer, its about when user sign up an email would be send to thanks them
but i cant make it work its been 3 days trying to solve this problem.
let transporter = nodemailer.createTransport({
host: "mail.********.com",
port: 465,
secure: true,
auth: {
user: "********",
pass: "********"
}
});
```[enter image description here](https://i.sstatic.net/51vX4ykH.png)
app.post(‘/signup’, (req, res) => {
const { name, email, password, gender, userType } = req.body;
const checkUserQuery = 'SELECT * FROM users WHERE email = ?';
connection.query(checkUserQuery, [email], (error, results) => {
if (error) {
console.error('Error checking user:', error);
return res.status(500).json({ success: false, message: 'Internal Server Error' });
}
if (results.length > 0) {
return res.status(400).json({ success: false, message: 'User already exists' });
}
const query = 'INSERT INTO users (name, email, password, gender, user_type, role) VALUES (?, ?, ?, ?, ?, ?)';
connection.query(query, [name, email, password, gender, userType, 'regular_user'], (error, results) => {
if (error) {
console.error('Error inserting user:', error);
return res.status(500).json({ success: false, message: 'Internal Server Error' });
}
const mailOptions = {
from: '********', // Use the correct sender email
to: email,
subject: 'Welcome to 4thRoom!',
text: `Hello ${name},nnThank you for registering with 4thRoom. We're excited to have you on board!nnBest regards,nThe 4thRoom Team`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {...
Ive tried using chatgpt and a lot of youtube videos but i still not able to make it work pls help.[[enter image description here](https://i.sstatic.net/f5QICOm6.png)](https://i.sstatic.net/xHMXr9iI.png)