Skip to content

Commit

Permalink
Added support new service https://tempmail.lol/
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Pitkov committed Feb 26, 2023
1 parent 560ee44 commit 17d0132
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 40 deletions.
2 changes: 1 addition & 1 deletion account_generator_helper/fake_data/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def get_password(length: int = 16, upper_case=True, numbers=True, special_symbol
data = {'upper_case': string.ascii_uppercase, 'numbers': string.digits, 'special_symbols': string.punctuation}
_data = locals()
letters = string.ascii_lowercase + ''.join([data[key] for key in list(_data)[1:4] if _data[key]])
return ''.join([random.choice(letters) for _ in range(length)])
return ''.join([random.choice(letters) for _ in range(length)])
2 changes: 1 addition & 1 deletion account_generator_helper/proxies/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ def __ne__(self, other):
return self.__str__() != str(other)

def __str__(self):
return self.strfproxy()
return self.strfproxy()
1 change: 1 addition & 0 deletions account_generator_helper/temp_mail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .inboxkitten import InboxKitten
from .tempmailplus import TempMailPlus, TempMailPlusDomains
from .gmailnator import GmailNator
from .tempmaillol import TempMailLol
4 changes: 4 additions & 0 deletions account_generator_helper/temp_mail/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ class NotSetEmail(Exception):

class ProblemWithGetEmail(Exception):
"""Problem receiving email"""


class CloudflareDetect(Exception):
"""Detect Cloudflare protection"""
24 changes: 11 additions & 13 deletions account_generator_helper/temp_mail/gmailnator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import requests
from ..exceptions import ProblemWithGetEmail
from ..exceptions import ProblemWithGetEmail, CloudflareDetect
from ..mail import Mail
from .letter import Letter
from urllib.parse import unquote
Expand All @@ -18,15 +17,14 @@ class GmailNator(Mail):

def __init__(self, proxy=None):
super().__init__(proxy)
self.__s = requests.Session()
if proxy:
self.__s.proxies.update(self._proxies)
self.__s.get('https://www.emailnator.com/')
r = self._s.get('https://www.emailnator.com/')
if r.status_code == 403:
raise CloudflareDetect()

def __get_xsrf_token(self):
token = self.__s.cookies.get('XSRF-TOKEN', '')
token = self._s.cookies.get('XSRF-TOKEN', '')
if not token:
print('Some problems, "emailnator.com" may have returned protection from Cloudflare')
raise CloudflareDetect()
return unquote(token)

def get_email(self):
Expand All @@ -43,8 +41,8 @@ def get_email_online(self, use_custom_domain=True, use_plus=True, use_point=True
"""
data = ['domain', 'plusGmail', 'dotGmail']
payload = json.dumps({'email': [i for i, k in zip(data, [use_custom_domain, use_plus, use_point]) if k]})
r = self.__s.post('https://www.emailnator.com/generate-email',
headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload)
r = self._s.post('https://www.emailnator.com/generate-email',
headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload)
if r.status_code == 200:
return self._set_email(r.json()['email'][0])
raise ProblemWithGetEmail()
Expand All @@ -57,9 +55,9 @@ def set_email(self, email):

def get_inbox(self):
payload = json.dumps({'email': self._email})
r = self.__s.post('https://www.emailnator.com/message-list',
headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload)
r = self._s.post('https://www.emailnator.com/message-list',
headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload)
if r.status_code == 200:
return [Letter(self._email, _letter, self._proxies, self.__get_xsrf_token(), self.__s) for _letter in r.json()['messageData'] if
return [Letter(self._email, _letter, self._proxies, self.__get_xsrf_token(), self._s) for _letter in r.json()['messageData'] if
'ADS' not in _letter['messageID']]
return []
3 changes: 1 addition & 2 deletions account_generator_helper/temp_mail/gmailnator/letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def letter(self):
if self._letter:
return self._letter
payload = json.dumps({'email': self._email, 'messageID': self._letter_id})
r = self._s.post('https://www.emailnator.com/message-list', proxies=self._proxies, data=payload,
headers={**headers, 'x-xsrf-token': self._token})
r = self._s.post('https://www.emailnator.com/message-list', data=payload, headers={**headers, 'x-xsrf-token': self._token})
if r.status_code == 200:
self._letter = re.sub(header_regex, '', r.text)
return self._letter
5 changes: 2 additions & 3 deletions account_generator_helper/temp_mail/inboxkitten/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from .letter import Letter
from ..exceptions import NotSetEmail
from ..mail import Mail
Expand All @@ -25,8 +24,8 @@ def get_inbox(self):
if not self._email:
raise NotSetEmail()

r = requests.get(f'https://inboxkitten.com/api/v1/mail/list?recipient={self._email}', proxies=self._proxies)
r = self._s.get(f'https://inboxkitten.com/api/v1/mail/list?recipient={self._email}')
if r.status_code == 200:
return [Letter(__letter['storage']['url'], __letter['message']['headers'], __letter['timestamp'],
self._proxies) for __letter in r.json()]
self._s) for __letter in r.json()]
return []
12 changes: 8 additions & 4 deletions account_generator_helper/temp_mail/inboxkitten/letter.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import re
import requests
from ..mail import letter
from datetime import datetime


class Letter(letter.Letter):
def __init__(self, url, headers, timestamp, proxies):
super().__init__(headers['to'], *re.findall(r'(.*) <(.*)>', headers['from'])[0], headers['subject'], datetime.fromtimestamp(timestamp), proxies)
def __init__(self, url, headers, timestamp, session):
if '<' in headers['from']:
name, from_email = re.findall(r'(.*) <(.*)>', headers['from'])[0]
else:
name = from_email = headers['from']
super().__init__(headers['to'], name, from_email, headers['subject'], datetime.fromtimestamp(timestamp))
self._letter_id = '-'.join(re.findall(r'https://(.*)\.api\.mailgun\.net/v3/domains/inboxkitten\.com/messages/(.*)', url)[0])
self._s = session

@property
def letter(self):
if self._letter:
return self._letter
r = requests.get(f'https://inboxkitten.com/api/v1/mail/getHtml?mailKey={self._letter_id}', proxies=self._proxies)
r = self._s.get(f'https://inboxkitten.com/api/v1/mail/getHtml?mailKey={self._letter_id}')
if r.status_code == 200:
self._letter = re.sub(r'<script[^>]*>([\s\S]*?)</script>', '', r.text)
return self._letter
7 changes: 7 additions & 0 deletions account_generator_helper/temp_mail/mail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import re
import time

import requests

from account_generator_helper.utilities import random_string
from .letter import Letter
from typing import List
Expand All @@ -17,6 +20,10 @@ def __init__(self, proxy=None):
self._proxies = {'http': proxy, 'https': proxy} if proxy else None
self._handlers = []

self._s = requests.Session()
if proxy:
self._s.proxies.update(self._proxies)

def get_email(self, *args, **kwargs) -> str:
"""
Generates a random address and returns it.
Expand Down
3 changes: 1 addition & 2 deletions account_generator_helper/temp_mail/mail/letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ class Letter:
"""
Base class of letter
"""
def __init__(self, email, name, from_email, subject, send_time, proxies, letter_id=None):
def __init__(self, email, name, from_email, subject, send_time, letter_id=None):
self._email = email
self._name = name
self._from_email = from_email
self._subject = subject
self._send_time = send_time
self._proxies = proxies
self._letter = None
self._letter_id = letter_id

Expand Down
34 changes: 34 additions & 0 deletions account_generator_helper/temp_mail/tempmaillol/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from .letter import Letter
from ..exceptions import NotSetEmail, ProblemWithGetEmail
from ..mail import Mail


class TempMailLol(Mail):
"""
Class for work with https://tempmail.lol/
"""

def __init__(self, proxy=None):
super().__init__(proxy)
self.__token = None

def get_email(self, community_addresses: bool = True):
"""
Get random email address from https://tempmail.lol/
:community_addresses: Community addresses use domains people have given to the website
"""
r = self._s.get('https://api.tempmail.lol/generate/rush' if community_addresses else 'https://api.tempmail.lol/generate')
if not r.ok:
raise ProblemWithGetEmail()
self.__token = r.json()['token']
return self.set_email(r.json()['address'])

def get_inbox(self):
if not self._email or not self.__token:
raise NotSetEmail()

r = self._s.get(f'https://api.tempmail.lol/auth/{self.__token}')
if r.status_code == 200:
return [Letter(_letter['to'], _letter['from'], _letter['subject'], _letter['date'], _letter['body']) for _letter in r.json().get('email', [])]
return []
12 changes: 12 additions & 0 deletions account_generator_helper/temp_mail/tempmaillol/letter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from ..mail import letter
from datetime import datetime


class Letter(letter.Letter):
def __init__(self, to, from_email, subject, timestamp, body):
super().__init__(to, from_email, from_email, subject, datetime.fromtimestamp(timestamp / 1000))
self.__body = body

@property
def letter(self):
return self.__body
5 changes: 2 additions & 3 deletions account_generator_helper/temp_mail/tempmailplus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import random
import requests
from .letter import Letter
from ..exceptions import NotSetEmail
from ..mail import Mail
Expand Down Expand Up @@ -30,7 +29,7 @@ def get_inbox(self):
if not self._email:
raise NotSetEmail()

r = requests.get(f'https://tempmail.plus/api/mails?email={self._email}&limit=100')
r = self._s.get(f'https://tempmail.plus/api/mails?email={self._email}&limit=100')
if r.status_code == 200:
return [Letter(self._email, _letter, self._proxies) for _letter in r.json()['mail_list']]
return []
return []
8 changes: 4 additions & 4 deletions account_generator_helper/temp_mail/tempmailplus/letter.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import requests
from ..mail import letter
from datetime import datetime


class Letter(letter.Letter):
def __init__(self, to, mail, proxies):
super().__init__(to, mail['from_name'], mail['from_mail'], mail['subject'], datetime.strptime(mail['time'], '%Y-%m-%d %H:%M:%S'), proxies)
def __init__(self, to, mail, session):
super().__init__(to, mail['from_name'], mail['from_mail'], mail['subject'], datetime.strptime(mail['time'], '%Y-%m-%d %H:%M:%S'))
self._letter_id = mail['mail_id']
self._s = session

@property
def letter(self):
if self._letter:
return self._letter
r = requests.get(f'https://tempmail.plus/api/mails/{self._letter_id}?email={self._email}', proxies=self._proxies)
r = self._s.get(f'https://tempmail.plus/api/mails/{self._letter_id}?email={self._email}')
if r.status_code == 200:
self._letter = r.json()['text']
return self._letter
6 changes: 3 additions & 3 deletions account_generator_helper/temp_phone/receive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ def get_counties(self) -> List[Country]:
"""
pass

def get_country(self, country: Counties) -> Country:
def get_country(self, phone_country: Counties) -> Country:
"""
Method returns object of the country, from this object you can get the phone number of this country.
:param country: Country.
:param phone_country: Country.
:return: Country object.
"""
if not self._countries:
self.get_counties()
result = self._countries.get(country, None)
result = self._countries.get(phone_country, None)
if not result:
raise NoCountyFound()

Expand Down
4 changes: 2 additions & 2 deletions account_generator_helper/temp_phone/receive_sms/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __parse(page_number):
except AttributeError:
_is_need_break = True

return [Phone(self._s, self._country, e.find('a')['href'], re.findall(r'.*/(\d*)/', e.find('a')['href'])[0], page.find('h1').text.split()[-1]) for e in page.find_all('li', {'class': 'wow'})], \
_is_need_break
return [Phone(self._s, self._country, e.find('a')['href'], re.findall(r'.*/(\d*)/', e.find('a')['href'])[0], page.find('h1').text.split()[-1])
for e in page.find_all('li', {'class': 'wow'})], _is_need_break

i = 0
while True:
Expand Down
33 changes: 33 additions & 0 deletions examples/temp_mail/tempmaillol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from account_generator_helper import TempMailLol


mail = TempMailLol()
print('Mail :', mail.get_email()) # Mail : [email protected]


for _letter in mail.get_inbox():
print('Letter :', _letter) # Letter : (Letter ..)
print('Letter content :', _letter.letter) # Letter content : ...


@mail.letter_handler()
def new_mail(letter):
print('New mail :', letter)


@mail.letter_handler(from_email='[email protected]')
def test_from(letter):
print('Test from :', letter)


@mail.letter_handler(re_subject='.* test .*')
def test_re_subject(letter):
print('Test re subject :', letter)


@mail.letter_handler(from_email='[email protected]', subject='Test letter')
def test_handler(letter):
print('Test handler :', letter)


mail.poling()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
certifi==2021.10.8
certifi==2022.12.7
charset-normalizer==2.0.12
idna==3.3
requests==2.27.1
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
long_description=long_description,
long_description_content_type='text/markdown',
python_requires='>=3',
keywords='python email captcha proxy pypi sms gmail temp-mail captcha-solving captcha-solver fake-data account-generator captcha-recognition fake-data-generator free-proxy recive-sms gmailnator gmailnator-api poxies',
keywords='python email captcha proxy pypi sms gmail temp-mail captcha-solving captcha-solver fake-data account-generator captcha-recognition '
'fake-data-generator free-proxy recive-sms gmailnator gmailnator-api poxies',
install_requires=required
)

0 comments on commit 17d0132

Please sign in to comment.