Skip to content

nboxhallburnett/last-gmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: '[email protected]',
    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);
}

About

Retrieves the last email sent to a gmail account

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •