Helo,我的节点邮件程序有这个问题,它是关于用户注册时会发送一封电子邮件来感谢他们 但我无法让它发挥作用,花了 3 天时间试图解决这个问题。
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 { 姓名、电子邮件、密码、性别、用户类型 } = 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},\n\nThank you for registering with 4thRoom. We're excited to have you on board!\n\nBest 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)
secure: false,