# yopmail-helper

A lightweight helper for retrieving the latest email from a [YOPmail](https://yopmail.com) inbox.

## 📦 Installation

Install via NPM:

```bash
npm i yopmail-helper
```

Or via Yarn:

```bash
yarn add yopmail-helper
```

## 🔧 Usage

The library exports a single function: `getLatestMailByEmailAddress(emailAddress)`.

```javascript
const { getLatestMailByEmailAddress } = require('yopmail-helper');

(async () => {
  try {
    const email = 'your-yopmail-username'; // Use just the username (e.g., 'admin01')
    const latestMail = await getLatestMailByEmailAddress(email);

    if (latestMail) {
      console.log('Latest Email Found:');
      console.log('ID:', latestMail.id);
      console.log('Title:', latestMail.title);
      console.log('Summary:', latestMail.summary);
      console.log('Time:', latestMail.time);
      console.log('Body:', latestMail.body);
    } else {
      console.log('No emails found in this inbox.');
    }
  } catch (error) {
    console.error('Error fetching mail:', error);
  }
})();
```

## ⚙️ Features

- Simple and straightforward API.
- Automatically handles YOPmail's versioning and permission requirements.
- Uses common browser-like headers to reduce scraping issues.

## 📄 License

MIT
