📬 getInbox()
The getInbox()
function in the Easy-YOPMail library provides a streamlined way to access and retrieve the contents of a YOPmail inbox. This function is essential for managing temporary email addresses and interacting with received messages programmatically.
Input Parameters
Parameter | Type | Description | Optional |
---|---|---|---|
| String | The YOPmail email address (without the @yopmail.com domain). | No |
| Object | An object containing search criteria to filter emails (e.g., { from: 'sender@example.com' }). | Yes |
| Object | An object containing settings for inbox retrieval (e.g., { LIMIT: 10 }). | Yes |
Purpose
The getInbox()
function serves the following purposes:
Inbox Retrieval: It fetches the inbox contents of a specified YOPmail address, providing a list of emails received at that address.
Email Management: By accessing the inbox, developers can programmatically manage emails, enabling actions like reading, deleting, or filtering messages based on various criteria.
Automation:
getInbox()
facilitates the automation of tasks involving temporary email addresses, such as collecting verification codes, monitoring for specific emails, or scraping data from received messages.
Functionality
The getInbox()
function performs the following actions:
Request Inbox Data: It sends an HTTP GET request to the YOPmail server, targeting the inbox of the provided email address. This request includes essential parameters like the email address and pagination details.
Parse Inbox HTML: Upon receiving the server response, the function parses the HTML content of the inbox page. It extracts key information about each email, including the sender, subject, timestamp, and a unique identifier.
Structure Inbox Data: The extracted information is then organized into a structured JavaScript object. This object provides an overview of the inbox, including the total number of emails, pagination details, and an array of email objects, each representing a single email in the inbox.
Apply Filtering (Optional): The
getInbox()
function can optionally accept asearch
object as a parameter. This object allows developers to filter the retrieved emails based on criteria like sender, subject, or timestamp.Return Inbox Object: Finally, the function returns the structured inbox object, containing all retrieved email information and relevant metadata.
Implementation
Here's an example demonstrating how to use getInbox()
in your Node.js project:
Optional Search Parameter
The search
parameter allows filtering emails based on specific criteria. Here's an example demonstrating its usage:
Conclusion
The getInbox()
function offers a versatile and efficient method to interact with YOPmail inboxes, empowering developers to automate tasks, manage temporary email addresses, and access received emails programmatically. By understanding its functionality and implementation, you can effectively leverage this tool in your Node.js projects.