last-gmail

3.0.0 • Public • Published

last-gmail

Simple wrapper around imap and mailparser that fetches, parses, and returns the most recent email that has been received by a gmail account.

Usage

Simply require in last-gmail, pass in the account details (only user and password are required, all other are optional and are documented here), and call getLastEmail. The async function returns the results, and any errors are thrown.

const gmail = require('last-gmail');

const opts = {
    user: 'example@gmail.com',
    password: 'password',
    mailbox: 'INBOX' // Optional, default: [Gmail]/All Mail
};

try {
    const email = await gmail.getLastEmail(opts);

    console.log('to:', email.to);
    console.log('from:', email.from);
    email.text && console.log('text:', email.text);
    email.html && console.log('html:', email.html);
} catch (err) {
    console.error(err);
}

Readme

Keywords

Package Sidebar

Install

npm i last-gmail

Weekly Downloads

2

Version

3.0.0

License

MIT

Unpacked Size

5.16 kB

Total Files

6

Last publish

Collaborators

  • nathanbb