A package for generating mails and addresses
Project description
FauxSynth
The Python package for generating addresses, temporary emails, and more. It scrapes the data from the internet and generates fake data for you.
Table of Contents
Installation
Download this repository and run the following command in the terminal to install the required packages.
pip install faux-synth
Usage
Random Address
FauxSynth provides multiple AddressGenerators
present in FauxSynth.address
module.
Each AddressGenerator
can generate multiple addresses from different countries.
In this example we will use the BestRandoms
address generator to generate random addresses from the United States.
from FauxSynth.address import BestRandoms
from FauxSynth.types import Country
# Create an instance of the AddressGenerator
address_generator = BestRandoms(Country.UnitedStates)
# Generate a random address
address = address_generator.get_address()
print(address)
# Generate multiple addresses
addresses = address_generator.get_addresses(5)
print(addresses)
# Access the address fields
print(address.street)
Temporary Email
FauxSynth provides multiple MailHandler
present in FauxSynth.mail
module.
Each MailHandler
can generate temporary emails.
In this example we will use the FakeMail
mail handler to generate a temporary email.
from FauxSynth.mail import FakeMail
mail_handler = FakeMail()
# FakeMail automatically has a random address.
# You can access it using the `address` property.
print(mail_handler.address)
# You can also generate a new random address by creating a new generator.
# Or claim a new address with `claim_mail()`
# Also check if the address is available with `check_mail()`
new_address = "max.mustermann"
if mail_handler.check_mail(new_address):
mail_handler.claim_mail(new_address)
print(mail_handler.address)
else:
print("Address already taken")
Receive Emails
To receive Emails using a MailHandler
you can use the refresh()
method.
This method will refresh the inbox and saves the new emails in the mails
property.
The mails
property is a list of Mail
objects. Each Mail
object has the following properties:
sender
: The sender of the emailsubject
: The subject of the emailbody
: The body of the email (Needs to be loaded withload_body()
)
from FauxSynth.mail import FakeMail
mail_handler = FakeMail()
print(f"Current Mail Address: {mail_handler.address}")
# Refresh the inbox
mail_handler.refresh()
# Print the mails
for mail in mail_handler.mails:
print(f"Sender: {mail.sender}")
print(f"Subject: {mail.subject}")
mail.load_body()
print(f"Body: {mail.body}")
print("")
There is also the wait_for_mail()
method.
This method will automatically refresh and wait for a new email to arrive.
from FauxSynth.mail import FakeMail
mail_handler = FakeMail()
# Wait for a new email
new_mail = mail_handler.wait_for_mail(timeout=60, interval=2)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file faux-synth-0.1.3.tar.gz
.
File metadata
- Download URL: faux-synth-0.1.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbecbcb18a46ee27095242b9675a7943b1a1b403f56050f01fa6c8ba5ecc8bef |
|
MD5 | bdd805ef5ab3ff510eda1ec8b5ecec47 |
|
BLAKE2b-256 | aa6ece9e28f0e3a8bfb009841c5936b6dab6d897ca573f84ab79bed7f83d9269 |