Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Cómo obtener datos de un nuevo mensaje de correo en node-imap

Necesito obtener información del mensaje de correo nuevo en el evento de mensaje de correo nuevo. Específicamente:

  • Dirección de correo electrónico que envió el correo
  • Título del mensaje
  • Contenido del mensaje (texto)

Mi código en este momento:

 let Imap = require('node-imap') let imap = new Imap({ user: '***@gmail.com', password: '***', host: 'imap.gmail.com', port: 993, tls: true }); imap.on('ready', () => { imap.openBox('INBOX', true, (err, box) => { if (err) console.log(err) else console.log('Recipient is ready for accepting') }) }) imap.on('mail', mail => { const title = ? const subject = ? const email = ? console.log(`Email author: ${email} Title: ${title}, Description: ${subject}`) }) imap.connect()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

imap.on('mail', ...) no proporcionó información de nuevos correos. Sólo un número de correos nuevos.

mail(< integer >numNewMsgs) - Emitido cuando llega correo nuevo al buzón actualmente abierto.

Para obtener los datos del correo, use imap.seq.fetch o imap.search . Puede encontrar algunos ejemplos aquí: https://github.com/mscdex/node-imap#connection-events

Tal vez esto ayude ( https://github.com/mscdex/node-imap/issues/359#issuecomment-37099842 ):

 imap.search([ 'NEW' ], function(err, results) { if (err || !results.length) return imap.end(); // fetch all resulting messages imap.fetch(results, ....); // or just fetch only the first result... which may not necessarily be newest // because the server can return results in any order imap.fetch(results[0], ...); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!