# last-gmail

> Retrieves the last email sent to a gmail account

Latest version **3.0.0** (published 2023-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install last-gmail
pnpm add last-gmail
yarn add last-gmail
bun add last-gmail
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-04-19 |
| First published | 2017-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^18.12.0 |
| Dependencies | 2 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nathan Boxhall-Burnett |
| Maintainers | nathanbb |
| Keywords | email, gmail, imap |

## Links

- npm: https://www.npmjs.com/package/last-gmail
- Repository: https://github.com/nboxhallburnett/last-gmail
- Homepage: https://github.com/nboxhallburnett/last-gmail#readme
- Issues: https://github.com/nboxhallburnett/last-gmail/issues
- npm.io page: https://npm.io/package/last-gmail

## Dependencies (2)

- [imap](https://npm.io/package/imap.md) 0.8.19
- [mailparser](https://npm.io/package/mailparser.md) 3.6.4

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2023-04-19
- 2.2.2 — 2023-04-19
- 2.2.1 — 2022-02-01
- 2.2.0 — 2021-06-21
- 2.1.2 — 2021-05-11
- 2.1.1 — 2021-05-08
- 2.1.0 — 2020-04-23
- 2.0.1 — 2020-01-06
- 2.0.0 — 2019-04-12
- 1.0.1 — 2017-07-18
- 1.0.0 — 2017-07-18

## README

# 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](https://github.com/mscdex/node-imap#connection-instance-methods)), and call `getLastEmail`. The async function returns the results, and any errors are thrown.

```javascript
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);
}
```

---
_Source: https://npm.io/package/last-gmail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
