easy-yopmail
Version:
Easy-YOPMail (get mail address, inbox and read mail from YOPMail with nodeJS)
57 lines (37 loc) • 3.36 kB
Markdown
# 🗑️ deleteInbox()
The `deleteInbox()` function in the Easy-YOPMail library provides a simple and efficient way to completely erase all emails within a specified YOPmail inbox. This function is especially useful when you need to clean up a temporary email address after its intended use, ensuring privacy and avoiding clutter.
## Input Parameters
| Parameter | Type | Description | Optional |
|---|---|---|---|
| `mail` | String | The YOPmail email address (without the @yopmail.com domain). | No |
## Purpose
The main purpose of `deleteInbox()` is to provide a programmatic way to clear out all messages from a YOPmail inbox. This is beneficial for several reasons:
- **Privacy:** By deleting the inbox, you ensure that any sensitive information potentially contained within the emails is permanently removed.
- **Cleanliness:** It helps maintain a clutter-free YOPmail account, especially if you use temporary email addresses frequently.
- **Automation:** `deleteInbox()` enables the automation of cleanup tasks, allowing you to seamlessly integrate inbox deletion into your workflows.
## Functionality
Internally, the `deleteInbox()` function performs the following steps:
1. **Inbox Check:** It first checks if the specified YOPmail inbox contains any emails. If the inbox is already empty, it returns a notification indicating that no action was taken.
2. **Prepare Deletion Request:** If emails are present, it constructs a specialized HTTP GET request designed to delete the entire inbox. This request includes essential parameters like the email address, security tokens, and a specific flag signaling a complete inbox deletion.
3. **Execute Deletion:** The crafted request is then sent to the YOPmail server. If successful, the server will process the request and permanently erase all emails within the targeted inbox.
4. **Return Confirmation:** Upon completion, the function returns a success message confirming the deletion of the inbox and the number of emails removed. In case of an error during the deletion process, it returns an error message indicating the failure.
## Implementation
Using `deleteInbox()` in your project is straightforward. Here's a simple example:
```javascript
const easyYopmail = require('easy-yopmail');
async function cleanupYopmailInbox() {
try {
const result = await easyYopmail.deleteInbox('your-yopmail-address');
console.log(result);
// Output: Success or error message based on the deletion result
} catch (error) {
console.error("Error:", error);
}
}
cleanupYopmailInbox();
```
## Important Notes
- **Permanence:** Deleting an inbox is irreversible. Once executed, the emails are permanently removed from the YOPmail server.
- **Error Handling:** It's important to handle potential errors during the deletion process. The function will throw an error if it encounters issues, allowing you to implement appropriate error handling mechanisms in your code.
## Conclusion
The `deleteInbox()` function simplifies the process of managing temporary email addresses by providing a quick and reliable way to erase their contents. This functionality is valuable for maintaining privacy, cleanliness, and automation in projects involving YOPmail. By integrating `deleteInbox()` into your workflows, you can ensure a secure and organized use of temporary email addresses.