UNPKG

yopmail-helper

Version:

yopmail helper. It will help you receive the mail content.

25 lines (22 loc) 751 B
const {getInbox} = require('./utils/inbox/inbox'); const {getMailDetails} = require('./utils/mail-details/mail-details'); /** * Get the latest mail details from a YOPmail address. * @param {string} mailAddress - The YOPmail email address or username. * @returns {Promise<Object|null>} - Returns the latest mail info (id, title, summary, time, body) or null if no mail found. */ async function getLatestMailByEmailAddress(mailAddress) { const mails = await getInbox(mailAddress); if (!mails || mails.length === 0) { return null; } const latestMail = mails[0]; const details = await getMailDetails(latestMail.id, mailAddress); return { ...latestMail, ...details, }; } module.exports = { getLatestMailByEmailAddress, };