-
Notifications
You must be signed in to change notification settings - Fork 21
/
trash-mail.js
30 lines (27 loc) · 989 Bytes
/
trash-mail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const axios = require('axios');
const mail_domain = 'rteet.com';
module.exports.getEmail = async login => {
const email = `${login}@${mail_domain}`;
return email;
};
module.exports.getAllMails = async username => {
const response = await axios.get(`https://www.1secmail.com/api/v1/?action=getMessages&login=${username}&domain=${mail_domain}`, {});
var output_array = JSON.parse(JSON.stringify(response.data));
return response.data;
};
module.exports.waitFirstMail = name => {
return new Promise(async resolve => {
const check = async () => {
const lastMail = await this.getAllMails(name);
if(lastMail[0])
{
subject = lastMail[0].subject;
const verfiy_code = subject.split('–')[0].replace(' ', '');
resolve(verfiy_code);
} else {
return setTimeout(async () => await check(), 1000);
}
};
await check();
});
};