Node.js Node JS-NodeEmailer&;imap简单-识别线程
(我为我糟糕的英语感到抱歉,但我会尽力的。):) 我正在尝试为personnal项目设置一个本地邮箱,我正在尝试使用imap simple和NodeEmailer来实现这一点 我希望在发送电子邮件时能够识别线程 下面是我想要做的: 在我的应用程序中,我将能够向特定的人发送电子邮件(让我们承认)foo@bar.com) 发送邮件时,回调函数将在DB中存储邮件内容和主题(例如,在CRM应用程序中,我将存储与数据库中特定记录相关的已发送邮件) 然后是复杂的部分: 当此人回复此电子邮件时,我希望使用IMAP识别此人是否正在回复我以前的邮件,然后将其也存储在DB中,并链接到我在第一封电子邮件中使用的相同记录 实际上,我在一个沙盒文件夹中有这个(对于IMAP): 以下是SMTP部分:Node.js Node JS-NodeEmailer&;imap简单-识别线程,node.js,smtp,imap,Node.js,Smtp,Imap,(我为我糟糕的英语感到抱歉,但我会尽力的。):) 我正在尝试为personnal项目设置一个本地邮箱,我正在尝试使用imap simple和NodeEmailer来实现这一点 我希望在发送电子邮件时能够识别线程 下面是我想要做的: 在我的应用程序中,我将能够向特定的人发送电子邮件(让我们承认)foo@bar.com) 发送邮件时,回调函数将在DB中存储邮件内容和主题(例如,在CRM应用程序中,我将存储与数据库中特定记录相关的已发送邮件) 然后是复杂的部分: 当此人回复此电子邮件时,我希望使用IM
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'catchall@xxxxxxxx.fr',
pass: 'xxxxxxxx'
}
});
const mailOptions = {
from: 'catchall@xxxxxxxx.fr', // sender address
to: 'xxxxxxxx@gmail.com', // list of receivers
subject: 'Subject of your email', // Subject line
html: '<p>Here is my test !</p>',// plain text body
headers: {
'collection': 'Pipelines',
'doc-ID': 'mydocid'
}
};
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log("Server is ready to take our messages");
}
});
transporter.sendMail(mailOptions, function (err, info) {
if(err)
console.log(err)
else
console.log(info);
});
x-gm-thrid允许我识别一个线程。也许,我在NodeEmailer回调函数中找不到以下信息:
Server is ready to take our messages
{ accepted: [ 'xxxxxxxxxxxxxxxxx@gmail.com' ],
rejected: [],
envelopeTime: 400,
messageTime: 819,
messageSize: 346,
response: '250 2.0.0 OK 1575566223 m3sm12955793wrs.53 - gsmtp',
envelope:
{ from: 'catchall@xxxxxxxxxx.fr',
to: [ 'xxxxxxxxxxxx@gmail.com' ] },
messageId: '<f93b3970-e17a-84b5-d0d1-ebb4fd6efe46@xxxxxxxxxx.fr>' }
服务器已准备好接收我们的消息
{已接受:['xxxxxxxxxxxxxxxxx@gmail.com' ],
已拒绝:[],
信封时间:400,,
留言时间:819,
邮件大小:346,
答复:“250 2.0.0正常1575566223 m3sm12955793wrs.53-gsmtp”,
信封:
{发件人:'catchall@xxxxxxxxxx.fr',
致:['xxxxxxxxxxxx@gmail.com' ] },
messageId:'}
有人知道我该怎么做吗
非常感谢强>
快乐编码:)对于那些将阅读本文的人,这里是答案,感谢@arnt 正如@arnt所说,IMAP协议中有一个
引用
属性,用于存储结果[0]中存储的上一个消息ID。部分[1]
:
references: [ '<23df0af1-8ff1-0ffa-091e-a645a38e4a67@foobar.fr>' ],
'in-reply-to': [ '<23df0af1-8ff1-0ffa-091e-a645a38e4a67@foobar.fr>' ],
这样,我们就能够关联邮件对话
非常感谢您的帮助:)
主题已关闭能否将其更改为
函数(err,info){..}
到函数(err,info,response){..}
并检查响应
参数中的内容。另外,x-gm-*
是gmail特有的标题。它不是由NodeEmailery返回的。您发送的邮件应包含邮件id
字段。响应将包含回复的,引用
,或者两者都包含传出消息的消息id,因此您可以轻松地将传出消息与响应关联起来。@AritraChakraborty,我尝试了响应参数,但其中显然没有任何内容:/@amt,好的,我明白了,您知道这是否出现在任何消息中,没有任何特定字段,如@AritraChakraborty forx-gm-*
?我试试看
Server is ready to take our messages
{ accepted: [ 'xxxxxxxxxxxxxxxxx@gmail.com' ],
rejected: [],
envelopeTime: 400,
messageTime: 819,
messageSize: 346,
response: '250 2.0.0 OK 1575566223 m3sm12955793wrs.53 - gsmtp',
envelope:
{ from: 'catchall@xxxxxxxxxx.fr',
to: [ 'xxxxxxxxxxxx@gmail.com' ] },
messageId: '<f93b3970-e17a-84b5-d0d1-ebb4fd6efe46@xxxxxxxxxx.fr>' }
references: [ '<23df0af1-8ff1-0ffa-091e-a645a38e4a67@foobar.fr>' ],
'in-reply-to': [ '<23df0af1-8ff1-0ffa-091e-a645a38e4a67@foobar.fr>' ],
envelope:
{ from: 'foobar@foobar.fr',
to: [ 'foobar@gmail.com' ] },
messageId: '<23df0af1-8ff1-0ffa-091e-a645a38e4a67@foobar.fr>' }