我正在使用优秀的收件箱节点.js库,对于某些电子邮件帐户,我没有看到一些默认邮箱,例如"已发送邮件"。我几乎在 OAUTH2 中按原样使用示例代码;
client = inbox.createConnection(false, "imap.gmail.com", {
secureConnection: true,
auth: {
XOAuth2: {
user: account.email,
clientId: Settings.googleApp.clientId,
clientSecret: Settings.googleApp.secretId,
refreshToken: refreshToken,
accessToken: accessToken,
timeout: expires
}
}
});
client.connect();
client.on("connect", function() {
Logger.debug("Opening mailbox " + mailbox);
self.getMailboxes(function(err, boxes){
var boxNames = _.pluck(boxes, 'name');
Logger.info(boxNames);
});
}
我有点难倒了。
谢谢,所以我最终使用了类型(type='Sent')并遍历了所有子邮箱以拉出所有已发送邮箱,这允许邮箱的区域设置特定名称。这是代码;
client.listMailboxes(function(error, mailboxes){
var _findSent = function(mailbox, callback){
if(mailbox.hasChildren){
mailbox.listChildren(function(error, children){
var sent = [];
for(var i=0; i < children.length; i++){
if (children[i].type == 'Sent'){
sent.push(children[i]);
}
}
callback(null, sent);
});
}
else {
var sent = [];
if (mailbox.type == 'Sent'){
sent.push(mailbox);
}
callback(null, sent);
}
}
async.map(mailboxes, _findSent, function(err, results){
onGotSentMailboxes(_.flatten(results));
});
});