我正在使用nodemailer发送电子邮件。但是我想回复一封邮件(开始一个新的线程)。我已经尝试使用以下代码来回复一封邮件:
var nodemailer = require('nodemailer');
const subject = 'Hey I am test';
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '*******',
pass: '*******'
}
});
const mailOptions = {
from: 'mymail@gmail.com',
to: 'receiver@gmail.com',
subject,
text: 'Body',
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log(info.messageId);
const threadOptions = {
from: 'mymail@gmail.com',
to: 'receiver@gmail.com',
subject:'Re: ' + subject,
text: 'This is reply',
inReplyTo: info.messageId,
references: [info.messageId]
};
transporter.sendMail(threadOptions);
}
});
但它会被发送作为一封新邮件。在文档中提到使用inReplyTo和references字段会开启一个新的线程,但这并没有起作用。
非常感谢任何帮助。