jasp402 / easy-yopmail Goto Github PK
View Code? Open in Web Editor NEW๐ฎ YOPmail emails manager from an NPM NodeJS library
Home Page: https://jasp402.github.io/Easy-YOPmail/starter-topic.html
๐ฎ YOPmail emails manager from an NPM NodeJS library
Home Page: https://jasp402.github.io/Easy-YOPmail/starter-topic.html
Sample Snippet
// const constants = require('../constants/constants.app');
const easyYopmail = require('easy-yopmail');
// const assert = require('assert');
// const fs = require('fs');
const k= async function(){
const inbox = await easyYopmail.getInbox("[email protected]", {}, {MAX_PAGE:1});
//Below code is not working
// const inbox1 = await easyYopmail.readMessage("[email protected]");
await console.log(JSON.stringify(inbox))
// await console.log(JSON.stringify(inbox1))
// await console.log(inbox1)
// await console.log(inbox1)
}
k();
Title: Error getting total number of mails
Labels: bug
Environment:
Steps to Reproduce:
๐ณ๏ธ Expected Behavior:
Return inbox array
๐ฉ Actual Behavior:
Found error message: Error getting total number of mails
๐ฌ Please let me know if you have any questions.
readMessage(): Error read message
Cannot read properties of undefined (reading 'toLowerCase')
D:\Coding\JS\Projects\InstaBotnet\node_modules\easy-yopmail\index.js:1
"use strict";const cheerio=require("cheerio"),querystring=require("querystring"),constants=require("./src/constants.js"),utils=require("./src/utils.js");class EasyYopmail{async getMail(){try{const a=await utils.request("GET",constants.GENERATOR_URL);if(200!==a.statusCode)return console.error(constants.ERROR_LOAD_PAGE),null;const b=cheerio.load(a.body),c=b(constants.S_INPUT_MAIL_GENERATE).text();return c.split(";")[1]||c}catch(a){throw console.error(constants.ERROR_LOAD_PAGE),console.error(a.message),new Error(a)}}async getInbox(a){let b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{};try{const d=utils.simplifyEmail(a),{cookie:e,yp:f,ver:g}=await utils.getCookiesAndYP(),h=await utils.getYJ(e,g);return await utils.detailInbox(d,f,h,g,e,b,c)}catch(a){throw console.error(constants.ERROR_GET_INBOX),console.error(a.message),new Error(a)}}async readMessage(a,b,c){let d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:"";try{const{cookie:e}=await utils.getCookiesAndYP(),f=await utils.request("GET",constants.READ_MAIL_URL(a,b),constants.INBOX_HTTP_CONFIG(e,a));200!==f.statusCode&&console.log(constants.ERROR_LOAD_PAGE);const g=cheerio.load(f.body),h=g(constants.SELECTOR_SUBMIT).text(),i=g(constants.SELECTOR_FROM),j=g(constants.SELECTOR_DATE),k=i.length?i.text():g(constants.SELECTOR_FROM_ALT).text(),l=j.length?j.text().replace(k,""):g(constants.SELECTOR_DATE_ALT).text();let m;return d?(d="".concat(constants.SELECTOR_MAIL," ").concat(d),m="html"===c.toLowerCase()?g(d).html():g(d).text().trim()):(d="#mail",m="html"===c.toLowerCase()?g(d).html():g(d).text().trim()),{id:b,submit:h,from:k,date:l,selector:d,format:c,data:m}}catch(a){throw console.error(constants.ERROR_READ_MESSAGE),console.error(a.message),new Error(a)}}async deleteMessage(a,b){try{const{cookie:c,yp:d,ver:e}=await utils.getCookiesAndYP(),f=await utils.getYJ(c,e),{inbox:g}=await this.getInbox(a,{id:b});if(0<g.length){const g=constants.DELETE_MESSAGE_URL(a,b,d,f,e),h=await utils.request("GET",g,constants.INBOX_HTTP_CONFIG(c,a));return!(200!==h.statusCode)}return!1}catch(a){throw console.error(constants.ERROR_DELETE_MESSAGE),console.error(a.message),new Error(a)}}async writeMessage(a,b,c,d){try{a&&b&&c&&d||console.error(constants.ERROR_MISSING_PARAMETERS);const{cookie:e}=await utils.getCookiesAndYP(),f=await utils.request("GET",constants.WRITE_MAIL_URL(a),constants.INBOX_HTTP_CONFIG(e,a));if(200===f.statusCode){const f={msgfrom:"".concat(a,"@yopmail.com"),msgto:b,msgsubject:c,msgbody:d},g=querystring.stringify(f);let h=constants.WRITE_MESSAGE_HTTP_CONFIG(e,a);h.headers["Content-Type"]="application/x-www-form-urlencoded",h.headers["Content-Length"]=Buffer.byteLength(g);const i=await utils.request("POST",constants.SEND_MESSAGE_URL,h,g);return 200!==i.statusCode&&console.error(constants.ERROR_WRITE_MESSAGE),(i.body+"").split("|")[2]}return f.data}catch(a){throw console.error(constants.ERROR_WRITE_MESSAGE),console.error(a.message),new Error(a)}}async deleteInbox(a){try{const{cookie:b,yp:c,ver:d}=await utils.getCookiesAndYP(),e=await utils.getYJ(b,d),{inbox:f}=await this.getInbox(a);if(0<f.length){const g=f[0].id,h=constants.DELETE_INBOX_URL(a,g,c,e,d),i=await utils.request("GET",h,constants.INBOX_HTTP_CONFIG(b,a));return console.log(i),200===i.statusCode}return!1}catch(a){throw console.error(constants.ERROR_DELETE_INBOX),console.error(a.message),new Error(a)}}}module.exports=new EasyYopmail;
Error: TypeError: Cannot read properties of undefined (reading 'toLowerCase')
at EasyYopmail.readMessage (D:\Coding\JS\Projects\InstaBotnet\node_modules\easy-yopmail\index.js:1:1796)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///D:/Coding/JS/Projects/InstaBotnet/index.js:50:31
Node.js v20.5.0
facing this issue when i use your snippet from the last issue, i have put my own mail and id in place where its needed
This library is essentially an HTTP web crawler for YOPMail and part of the problem with automated web scraping is when websites begin implementing anti-bot like reCAPTCHA.
I've noticed a sharp increase in reCAPTCHA serving from YOPMail and saw another ticket on here which concluded that something about CAPTCHA needed to be implemented. Since the code base is minimized and obfuscated, I can't (very easily) see what you are doing for your web requests, but I imagine that it's all hard coded headers, fingerprints, etc. which is why this library has been easy to target for serving CAPTCHAs.
One consideration could be switching to the Crawlee CheerioCrawler to maintain the raw HTTP requests with better browser header and fingerprint rotation to reduce the instances of CAPTCHAs being served.
https://crawlee.dev/docs/guides/cheerio-crawler-guide
I wouldn't mind helping in the contribution if you were able to switch to a two branch structure (a dev branch you work from that is not obfuscated and minified and a main branch which holds the obfuscated and minified code that is packaged up for the npm package).
Hi,
I am getting this error easyYOPmail.readMail is not a function, none of them is working
When attempting to get an email via
const message = await easyYop.readMessage("[email protected]", id, { format: "HTML" });
I am presented with the error
readMessage(): Error read message
- readMessage(): The message has been deleted or does not exist. Try reviewing the ID
However, the email and message does exist. When I call:
const inboxResponse = await easyYop.getInbox("[email protected]");
I receive the expected messages:
[{
id: "e_ZwDjAwR3ZGpkAGHlZQNjAmR4BGVjAj==",
from: "...",
subject: "...",
timestamp: "17:15",
page: 1,
}]
When troubleshooting, I noticed that when I looked up the messages on YOPMail, they show the email address with all lowercase letters. So changing my initial request to
// Notice I changed it to all lowercase
const message = await easyYop.readMessage("[email protected]", id, { format: "HTML" });
I get the email message successfully.
Thus, it's likely that when attempting to get messages, the email address should be converted to lowercase prior to querying YOPMail.
Hi @jasp402, due to recent changes of Yopmail seems this packages stopped working ๐ข
Have you take a look at it recently?
Hey ! When i try to getInbox of mail i have a axios error ^^
const easyYOPmail = require('easy-yopmail');
(async () => {
let email = await easyYOPmail.getMail()
let mail = await easyYOPmail.getInbox("[email protected]")
console.log(mail)
})();```
Problems arise when using versions of Node JS below v12.x. Can lower versions of Node JS be supported?
For examplev10.15.2
. Thanks.
readMessage(): Error read message
Request failed with status code 400
Error reading message: Error: AxiosError: Request failed with status code 400
at Object.readMessage (C:\Users\xx\node_modules\easy-yopmail\dist\index.js:1:2504)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {stack: 'Error: AxiosError: Request failed with statusโฆions (node:internal/process/task_queues:95:5)', message: 'AxiosError: Request failed with status code 400'}
hey, i was trying to read messages from my mail, but everything is empty,
{
settings: {},
search: {},
totalInbox: 1,
totalPages: 1,
mailFromPage: { page_1: 1 },
totalGetMails: 1,
inbox: [
{
id: 'e_ZwDjAGVkZGVlAwHmZQNjAGR4ZwH1Zj==',
from: 'Instagram',
subject: '****** is your Instagram code',
timestamp: '18:26'
}
]
}
Hello,
It seems to me that the readMessage function does not return attached files. it would be nice to be able to get thoses as well.
The link of the attached file is present on the mail and then be able to download it.
Error: connect ETIMEDOUT 199.59.149.236:443
getMail(): Error getting YOPMail page
connect ETIMEDOUT 199.59.149.236:443
node:internal/process/promises:279
Title: Can't npm install
Labels: bug
Environment:
Steps to Reproduce:
๐ณ๏ธ Expected Behavior:
Library installed
๐ฉ Actual Behavior:
npm ERR! errno -4058
๐ท Screenshots / Live demo link:
๐งฎ Additional Context:
None
๐ค I expected npm to successfully install the library, but instead it failed with errno -4058
.
It always says invalid email id it's not working anymore
Title: How to bypass google captcha to get mail list?
About: Suggest an idea for this project
It looks like v4.x used to be written in JS on the master branch as the source of truth. Now it seems that it's being developed locally on a private branch as the source of truth and you have local scripts that minify the JS and push it to the main branch.
If I wanted to contribute, how can I do so since I can't code against the minified JS?
Title: [Short and descriptive title]
Labels: bug
Environment:
Steps to Reproduce:
const easyYOPmail = require('easy-yopmail');
easyYOPmail.getInbox('[email protected]').then(inbox => {
console.log(inbox);
})
The email exists, it was created with the current API.
๐ณ๏ธ Expected Behavior:
inbox gets fetched
๐ฉ Actual Behavior:
Error:
getInbox(): Error getting Inbox page
Request failed with status code 403
Hello,
I am trying to read emails from YOPMail address using following code:
const easyYopmail = require('easy-yopmail');
const AUTOMATION_EMAIL = '[email protected]';
easyYopmail.getInbox(AUTOMATION_EMAIL).then(emails => {
emails.inbox.forEach(msg => {
easyYopmail.readMessage(AUTOMATION_EMAIL, msg['id']).then(objMsg => {
console.log(objMsg);
});
});
});
When I run this code, I am experiencing following error:
PS D:\Development\Projects\Sandbox\YOPMailUtility> node app.js
D:\Development\Projects\Sandbox\YOPMailUtility\node_modules\easy-yopmail\src\core.js:1
"use strict";function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}const fs=require("fs"),zlib=require("zlib"),https=require("https"),cheerio=require("cheerio"),constants=require("./constants");class Core{constructor(){_defineProperty(this,"validateSelectAttrEQ",((a,b,c,d,e)=>(b&&0===a(b).length?e.push("Warning - The selector <".concat(b,"> is not found in the html.")):d>a(b).length&&e.push("Warning - The eq(".concat(d,") is greater than the number of elements found in the selector ").concat(b,".")),e))),_defineProperty(this,"getContentBySelectorForTxt",((a,b,c,d,e)=>{let f=[];return e=this.validateSelectAttrEQ(a,b,c,d,e),b||(f+=a(this.constants.S_MAIL).text().replace(/\s+|\n/gm," ").trim()),b&&!d&&a(b).each(((b,c)=>{f.push(a(c).text().trim())})),b&&d&&(f+=a(b).eq(parseInt(d,10)).text().replace(/\s+|\n/gm," ").trim(),!f&&e.push("Warning - No text found with selector <".concat(b,"> and .eq(").concat(d,")"))),{info:e,content:f}})),_defineProperty(this,"getContentBySelectorForHTML",((a,b,c,d,e)=>{let f;if(e=this.validateSelectAttrEQ(a,b,c,d,e),!b)return f=a.html(this.constants.S_MAIL),{info:e,content:f};if(f=(()=>c?void 0!==d&&null!==d?a(b).eq(parseInt(d,10)).attr(c):a(b).map(((b,d)=>a(d).attr(c))).toArray():void 0!==d&&null!==d?a(b).eq(parseInt(d,10)).html():a(b).map(((b,c)=>a.html(c))).toArray())(),!f||Array.isArray(f)&&!f.length){let a="Element not found";a+=" with selector ".concat(b),a+=c?" and attribute ".concat(c):"",a+=void 0===d?"":" and eq ".concat(d),e.push(a)}return{info:e,content:f}})),this.constants=constants,this.cwd=process.cwd()}async request(a,b){let c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;b||this.handleError({customMessage:this.constants.ERROR_URL_NOT_FOUND});const e=(a,b)=>{const c=Buffer.concat(b).toString();return{statusCode:a.statusCode,headers:a.headers,body:c}},f=(a,b,c)=>{const d=a.headers["content-encoding"];let f=a;"gzip"===d?f=a.pipe(zlib.createGunzip()):"deflate"===d&&(f=a.pipe(zlib.createInflate()));const g=[];f.on("data",(a=>g.push(a))),f.on("end",(()=>b(e(a,g)))),f.on("error",(a=>c(a)))},g=((a,b,c)=>{const d=new URL(a);return{hostname:d.hostname,port:443,path:"".concat(d.pathname).concat(d.search),method:b.toUpperCase(),...c}})(b,a,c),h=(a,b)=>new Promise(((c,d)=>{const e=https.request(a,(a=>{f(a,c,d)}));e.on("error",(a=>d(a))),a.body&&e.write(a.body),"POST"===a.method&&b&&e.write(b),e.end()}));try{return await h(g,d)}catch(a){this.handleError({customMessage:"Request Error",error:a})}}async getHttpSettings(){try{const a=await this.request("GET",this.constants.URL_BASE);200!==a.statusCode&&this.handleError({customMessage:this.constants.ERROR_GET_COOKIES});const b=this.loadHTMl(a.body),c=b(this.constants.S_INPUT_YP).val(),d=a.headers["set-cookie"].map((a=>a.split(";")[0])).join("; "),e=a.body.match(this.constants.REGEX_LOCATION)[1],f=a.body.match(this.constants.REGEX_VER)[1],g=await this.request("GET",this.constants.URL_WEBMAIL_JS(f),{headers:{Cookie:d}});200!==g.statusCode&&this.handleError({customMessage:this.constants.ERROR_GET_YJ});const h=g.body.match(this.constants.REGEX_YJ),i=h?h[1]:null,j=this.timeStampInSeconds(),k=this.timeStampInSeconds(),l=this.obtenerYTime(j);return{location:e,version:f,cookie:d,yp:c,yj:i,T:j,RT:k,ytime:l}}catch(a){return this.handleError({customMessage:this.constants.ERROR_GET_COOKIES,error:a}),null}}async detailInbox(a,b,c,d){const{location:e,version:f,cookie:g,yp:h,yj:i,T:j,RT:k,ytime:l}=d,m=15;let n=1,o=!0,p={},q=0,r=[],s={};const t=async(a,b,c,d,e,f,g)=>{let h=constants.URL_INBOX(a,b,c,d,f,g),i=constants.HEADERS_INBOX(e,a,g,j,k,l);const m=await this.request("GET",h,i);return 200!==m.statusCode&&this.handleError({customMessage:constants.ERROR_LOAD_PAGE}),m};b&&0<Object.keys(b).length&&(s=this.validateSearch(b));const u=await t(a,h,i,f,g,1,e),v=u.body,w=this.getTotalMails(v);for(;o;){const b=1===n?v:(await t(a,h,i,f,g,n,e)).body,d=this.getDetailInboxFromPage(b,s,n);p["page_".concat(n)]=d.length,q=n,r.push(...d),n*m>=w||n>=c.LIMIT?o=!1:n+=1}return{mail:"".concat(a,"@yopmail.com"),settings:c,filteredSearch:s,pageCount:Math.ceil(w/m),totalEmails:w,emailsPerPageCount:p,exploredPageCount:q,fetchedEmailCount:r.length,inbox:r}}getDetailInboxFromPage(a,b,c){const d=this.loadHTMl(a),e=d(".m");return e.map(((a,b)=>this.parseEmail(b,c))).toArray().filter((a=>this.shouldIncludeEmail(a,b)))}loadHTMl(a){return cheerio.load(a)}getTotalMails(a){const b=a.match(constants.REGEX_TOTAL_MAILS);let c=0;return b&&(c=b[1].split(",")[0]),+c}saveEmailHTML(a,b,c){let d="".concat(this.cwd,"/").concat(a);fs.existsSync(d)||fs.mkdirSync(d,{recursive:!0}),fs.writeFileSync("".concat(d,"/emailPage_").concat(c,".html"),b,(function(a){if(a)return new Error(a)}))}validateSearch(a){const b=["id","from","subject","timestamp"],c=b.some((b=>Object.keys(a).includes(b)||null));return c||this.handleError({customMessage:this.constants.ERROR_PARAMETERS_INVALID,error:new Error}),Object.keys(a).reduce(((c,d)=>(b.includes(d)&&(c[d]=a[d]),c)),{})}parseEmail(a,b){const c=cheerio.load(a),d=c(a).attr("id"),e=c(a).find(".lmh").text(),f=c(a).find(".lmf").text(),g=c(a).find(".lms").text();return{id:d,from:f,subject:g,timestamp:e,page:b}}shouldIncludeEmail(a,b){return Object.entries(b).every((b=>{let[c,d]=b;return"id"===c?a.id===d:"from"===c?a.from===d:"subject"===c?a.subject===d:!("timestamp"!==c)&&a.timestamp===d}))}obtenerYTime(a){const b=new Date(1e3*a),c=b.getHours(),d=b.getMinutes();return"".concat(c,":").concat(d)}timeStampInSeconds(){return Math.floor(Date.now()/1e3)}simplifyEmail(a){return-1<a.indexOf("@")?(a.split("@")[0]||"").toLowerCase():a.toLowerCase()}validateReadMessageOpt(a){const{format:e="txt",selector:b,attribute:c,pathToSave:d}={...{format:"txt",selector:null,attribute:null,pathToSave:null},...a};a={format:e.toLowerCase(),selector:b,attribute:c,pathToSave:d,eq:null};let f=[];const g=(a,b,c)=>{["html","txt"].includes(b.toLowerCase())||(c.push("Warning - the format ".concat(b," is incorrect, the default format is TXT")),a.format="txt")},h=(a,b,c)=>{const d=null===b||void 0===b?void 0:b.match(/^(.+)\.eq\((\d+)\)$/);if(d){const[,b,c]=d;a.eq=c,a.selector=b}else if(null!==b&&void 0!==b&&b.includes(".eq(")){const[d]=b.split(".eq(");a.selector=d,a.eq=null,c.push('Warning - the ".eq()" value is invalid, the default eq is null')}},i=(a,b,c,d)=>{c&&!b?(d.push("Warning - the attribute requires a selector, the default attribute is null"),a.attribute=null):c&&"string"!=typeof c&&(d.push("Warning - the attribute ".concat(c," is incorrect, the default attribute is empty")),a.attribute=null)},j=(a,b,c)=>{b&&"string"!=typeof b&&(c.push("Warning - the pathToSave ".concat(b," is incorrect, the default pathToSave is empty")),a.pathToSave=null)};return g(a,e,f),((a,b,c)=>{b&&"string"!=typeof b?(c.push("Warning - the selector ".concat(b," is incorrect, the default selector is null")),a.selector=null):h(a,b,c)})(a,b,f),i(a,b,c,f),j(a,d,f),{opt:a,info:f}}handleError(){let{customMessage:b=this.constants.ERROR_LOAD_PAGE,error:a}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};throw null!==a&&void 0!==a&&a.message&&(b+="\n - ".concat(a.message)),new Error(b)}}module.exports=Core;
Error: Error getting cookies
- Error getting cookies
at EasyYopmail.handleError (D:\Development\Projects\Sandbox\YOPMailUtility\node_modules\easy-yopmail\src\core.js:1:7631)
at EasyYopmail.getHttpSettings (D:\Development\Projects\Sandbox\YOPMailUtility\node_modules\easy-yopmail\src\core.js:1:3787)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async EasyYopmail.getInbox (D:\Development\Projects\Sandbox\YOPMailUtility\node_modules\easy-yopmail\index.js:1:711)
Node.js v22.5.1
I am running easy-yopmail v5.1.0. Could it be a configuration issue? Any advice will be appreciated!
Sincerely,
Aleksei
reCAPTCHA use TLS handshakes to determine whether a request is coming from a legitimate browser. Browsers handle these through specific protocols, client hello messages, and cipher suites. Node's https module allows you to define these protocols and ciphers, which can be useful for making requests seem legitimate, that is, in the case CAPTCHA solving support would ever be added.
Most CAPTCHA solvers nowadays do not require an extension and have API support, would that solve the seeming problem of CAPTCHA solvers requiring extensions?
reCAPTCHA is also pretty loose when detecting bots, so at least in my experience, it isn't much of a hassle.
Also, most CAPTCHA solvers are pretty much the same, all you'd need to do is allow for custom domain parameters.
After a few requests the service stop responding and asks for capture
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.