I am trying to create a webmail system with React and nodeJS, and I have no clue as to if I am doing it correctly... I have searched on Google, and read everything I could, but still have no idea. I purchased a domain for email, built a mail server with MailEnable, and currently using nodeJs libraries such as Imap, and nodemailer for both sending/receiving emails. Is this a correct way to make a webmail client? or is there a standard way of creating it?
I'm asking this because I'm having so many errors. For example, fetching emails with attachments takes so much time, especially when the file size is big.
and since it is not about reading a list of emails, I need to read the whole message to display email like this

The code for reading email is as below:
const {
simpleParser
} = require('mailparser');
imap.openBox(box_name, false, () => {
const criteria = ["uid", no];
imap.search([criteria], (err, results) => {
const f = imap.fetch(results, {
bodies: ''
});
f.on('message', msg => {
console.log("Flags: " + msg.flags);
msg.on('body', stream => {
simpleParser(stream, async (err, parsed) => {
// const {from, subject, textAsHtml, text} = parsed;
var obj = new Object();
obj["parsed"] = parsed;
view_data.push(obj);
});
f.once('error', ex => {
return Promise.reject(ex);
});
f.once('end', () => {
console.log('Done fetching!');
});
});
})
})
})
I get the correct results. It's just that it is too slow when the email has an attachment file with it. Would there be any way to solve this problem? Thanks in advance