Answer the question
In order to leave comments, you need to log in
How to get mail.ru mailings in IMAP?
Welcome all.
I'm trying to receive emails from mail.ru using the imap protocol (either - emailjs-imap-client), emails are received only from the inbox, but if the email is included in the mailing list, then this email is not returned.
Code example
const ImapClient = require('emailjs-imap-client').default;
(async () => {
// Initialize imap client
const client = new ImapClient('imap.mail.ru', 993, {
logLevel: 1000,
auth: {
user: '',
pass: ''
}
});
// Handling imap mail error
client.onerror = (err) => {
throw new Error(`Error IMAP handling: ${err}`);
};
// Create mail connection
await client.connect();
// Getting messages on mail
const listMessages = await client.listMessages('INBOX', '1:*', ['uid', 'flags', 'envelope', 'body[]']);
for (const message of listMessages) {
const messageDate = new Date(message.envelope.date);
const messageSubject = message.envelope.subject;
const messageBody = message['body[]'];
console.log(messageSubject);
}
// Close mail connection
await client.close();
})();
Answer the question
In order to leave comments, you need to log in
Well, not being a programmer, I see that you receive items only from the inbox:
Probably you need to rewrite the code so that it recursively bypasses all folders.
As akelsey correctly noted above, you receive mail only from the INBOX box, in order to receive mail from all boxes, you need to get all these boxes, and row letters for them separately.
This is how I got the list of boxes
and got this answer
{ root: true,
children:
[ { name: 'INBOX',
delimiter: '/',
path: 'INBOX',
children: [Array],
flags: [Array],
listed: true },
{ name: 'Нежелательная почта',
delimiter: '/',
path: '&BB0ENQQ2BDUEOwQwBEIENQQ7BEwEPQQwBE8- &BD8EPgRHBEIEMA-',
children: [],
flags: [],
listed: true },
{ name: 'Нужное',
delimiter: '/',
path: '&BB0EQwQ2BD0EPgQ1-',
children: [],
flags: [],
listed: true },
{ name: 'Спам',
delimiter: '/',
path: '&BCEEPwQwBDw-',
children: [],
flags: [Array],
listed: true,
specialUse: '\\Junk' },
{ name: 'Отправленные',
delimiter: '/',
path: '&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-',
children: [],
flags: [Array],
listed: true,
specialUse: '\\Sent',
specialUseFlag: '\\Sent' },
{ name: 'Черновики',
delimiter: '/',
path: '&BCcENQRABD0EPgQyBDgEOgQ4-',
children: [],
flags: [Array],
listed: true,
specialUse: '\\Drafts',
specialUseFlag: '\\Drafts' },
{ name: 'Корзина',
delimiter: '/',
path: '&BBoEPgRABDcEOAQ9BDA-',
children: [],
flags: [Array],
listed: true,
specialUse: '\\Trash',
specialUseFlag: '\\Trash' } ] }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question