node-1smail
v2.0.0
Published
Async Node.js API for https://www.1secmail.com/
Downloads
12
Maintainers
Readme
node-1smail
Async Node.js API for https://www.1secmail.com/
Installation
npm i node-1smail
- Importing
import { TempMail } from "node-1smail";
Usage
Create temporary e-mail
Create e-mail
const mail = await TempMail.init("myownlogin", "laafd.com");
//Create random e-mail address
await TempMail.init();
//Create e-mail address with your username and random domain
await TempMail.init("username");
//Create e-mail address with your username and domain
await TempMail.init("username", "1secmail.org");
//Full domain list you can see there: https://www.1secmail.com/api/v1/?action=getDomainList
Get e-mail address
Return full e-mail address
mail.getAddress(); // => [email protected]
Get messages
Return JSON-object with messages
await mail.getMessages();
//return message list or wait for any message if there no one
await mail.getMessages(true);
//wait for new message with id > lastMessageId
Messages list example
[
{
id: 639,
from: "[email protected]",
subject: "Some subject",
date: "2018-06-08 14:33:55",
},
{
id: 640,
from: "[email protected]",
subject: "Other subject",
date: "2018-06-08 14:40:55",
},
];
Get message data
Return JSON-object with one message
const msgID = 639; //message ID for this e-mail
await await mail.getMessageData(msgID);
Returns
{
"id": 639,
"from": "[email protected]",
"subject": "Some subject",
"date": "2018-06-08 14:33:55",
"attachments": [{
"filename": "iometer.pdf",
"contentType": "application\/pdf",
"size": 47412
}],
"body": "Some message body\n\n",
"textBody": "Some message body\n\n",
"htmlBody": ""
}
Get links to attached files
Returns links for attached files
const msg = await mail.getMessageData(639);
mail.getLinksToFiles(msg);
Example
[
"https://www.1secmail.com/api/v1/?action=download&login=username&domain=1secmail.org&id=639&file=iometer.pdf",
];