Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.pop3.on('retr', Meteor.bindEnvironment((status, msgnumber, data) => {
if (status) {
// parse raw email data to JSON object
simpleParser(data, Meteor.bindEnvironment((err, mail) => {
this.initialProcess(mail);
}));
this.currentMsgCount += 1;
// delete email
this.pop3.dele(msgnumber);
} else {
console.log('Cannot Retrieve Message ....');
}
}));
function createFrom (request) {
const Q = require('q'),
deferred = Q.defer();
const simpleParser = require('mailparser').simpleParser;
simpleParser(request.source, (err, mail) => {
if (err) {
deferred.reject(err);
}
else {
deferred.resolve(transform(request.session, mail));
}
});
return deferred.promise;
}
function _mp(plugin, connection, cb) {
simpleParser(connection.transaction.message_stream, { Iconv, 'skipImageLinks' : true }, (error, mail) => {
if ( mail && mail.attachments ) {
_storeAttachments(connection, plugin, mail.attachments, mail, function(error, mail_object) {
return cb(error, mail_object);
});
}
else {
return cb(error, mail);
}
});
}
function toJSON(source) {
return parseMail(source)
.then(attachment)
.then(convert);
}
function parseEmail(stream) {
return simpleParser(stream).then(email => {
if (config.headers) {
email.headers = formatHeaders(email.headers);
} else {
delete email.headers;
}
return email;
});
}
function parse(buffer) {
debugParser('got buffer %s', buffer);
return simpleParser(buffer);
}
const ParserMail = async (data) => {
const mail = await parser(Buffer.from(data, 'binary'));
let content = mail.html || mail.textAsHtml;
if (mail.attachments.length > 0) {
content += `<h3>附件(${mail.attachments.length})</h3>`;
mail.attachments.forEach((attachment) => {
content += `<p>${attachment.filename}</p>`;
});
}
return content;
};
function toJSON(source) {
return parseMail(source).then(convert);
}