### imapbox Local Installation (Bash) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Provides step-by-step commands for cloning the imapbox repository from GitHub, navigating into the directory, setting up a Python virtual environment, activating the environment, and installing the required Python dependencies using pip. ```bash git clone https://github.com/bananaacid/imapbox.git ./imapbox cd imapbox python -m venv ./ # mac/bash/wsl source ./bin/activate # ps1 .\Scripts\Activate.ps1 pip install --no-cache-dir -r requirements.txt # install GUI lib, requires compiler tools and more - optional pip install --no-cache-dir -r requirements_optional.txt cd .. ``` -------------------------------- ### Example Configuration File - Imapbox INI Source: https://github.com/bananaacid/imapbox/blob/master/README.md Provides an example of the `imapbox` configuration file in INI format. It defines global settings like the local folder, days to keep, and optional `wkhtmltopdf` path, as well as multiple account configurations using host/username/password or DSN formats. ```ini [imapbox] local_folder=/var/imapbox days=6 wkhtmltopdf=/opt/bin/wkhtmltopdf specific_folders=True # test_only=True ## cron -> At minute 0 past every 4th hour -> see https://crontab.guru/#0_*/4_*_*_* # server=0 */4 * * * [accountName1] host=mail.domain.tld username=username@domain password=secret ssl=True [username2@gmail.com] host=imap.googlemail.com username=username2@gmail.com password=secret remote_folder=INBOX exclude_folder=Junk port=993 [username3@domain.tld] dsn=imaps://username:password@domain.tld/__ALL__?exclude_folder=Trash [username4@domain.tld] username=username4@domain.tld password=secret dsn=imaps://domain.tld/__ALL__ ``` -------------------------------- ### wkhtmltopdf Installation (Multi-platform) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Commands to install the optional `wkhtmltopdf` dependency, which is required for archiving emails to PDF. Includes commands for Debian-based Linux distributions, macOS using Homebrew, and Windows using Chocolatey. ```bash # Linux, debain based apt install wkhtmltopdf # MacOs Homebrew brew install wkhtmltopdf # Windows Chocolatey choco install wkhtmltopdf ``` -------------------------------- ### imapbox Bash Search Examples with jq Source: https://github.com/bananaacid/imapbox/blob/master/README.md Demonstrates using standard Unix commands (`find`, `xargs`, `cat`) piped into `jq`, a command-line JSON processor, to process imapbox metadata JSON files. Examples show how to browse emails by extracting key fields and how to filter emails based on the UTC date. ```bash find . -name "*.json" | xargs cat | jq '[.Date, .Id, .Subject, " ✉ "] + .From | join(" ")' ``` ```bash find . -name "*.json" | xargs cat | jq 'select(.Utc > "20150221T130000Z")' ``` -------------------------------- ### Build Executable with PyInstaller (Linux/WSL Bash) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Installs PyInstaller and builds a single-file executable for imapbox.py on Linux or WSL using bash. Includes the VERSION file as data. ```bash pip install --no-cache-dir pyinstaller pyinstaller --add-data "VERSION:." --onefile ./imapbox.py ``` -------------------------------- ### imapbox Powershell Search Examples Source: https://github.com/bananaacid/imapbox/blob/master/README.md Shows how to use Powershell cmdlets like `Get-ChildItem` (`gci`), `Get-Content` (`gc`), `ConvertFrom-Json`, and `Where-Object` (`?`) to read and filter imapbox metadata JSON files recursively. Includes examples for filtering by Subject, From, Date, and UTC date. ```powershell gci -r -filter *.json |% { gc $_ | ConvertFrom-Json } |? { $_.Subject -imatch "Welcome" } ``` ```powershell gci -r -filter *.json |% { gc $_ | ConvertFrom-Json } |? { $_.From -imatch "Support" } ``` ```powershell gci -r -filter *.json |% { gc $_ | ConvertFrom-Json } |? { $_.Date -imatch "13 Aug 2024" } ``` ```powershell gci -r -filter *.json |% { gc $_ | ConvertFrom-Json } |? { $_.UTC -gt "20240813T164821Z" } ``` -------------------------------- ### Quick Use with Binary - Imapbox Bash Source: https://github.com/bananaacid/imapbox/blob/master/README.md Demonstrates a quick command-line usage example of the Imapbox binary. It specifies the local backup folder (`-l`) and provides the IMAP account details using a DSN (`--dsn`) to archive all folders (`__ALL__`). ```bash imapbox -l ./backup --dsn imaps://username:password@imap.server.tld/__ALL__ ``` -------------------------------- ### Run Local Test with Docker Compose Source: https://github.com/bananaacid/imapbox/blob/master/README.md Starts the services defined in the local test docker-compose file to test the imapbox application. Requires specific local folders and a config file to exist. ```bash docker compose -f ./docker-compose.local-test.yml up ``` -------------------------------- ### Build Executable with PyInstaller (Windows Powershell) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Installs PyInstaller and builds a single-file executable for imapbox.py on Windows using Powershell. Includes the VERSION file as data and specifies a custom icon. ```powershell pip install --no-cache-dir pyinstaller pyinstaller --add-data "VERSION:." --onefile .\imapbox.py --icon .\resources\logo.ico ``` -------------------------------- ### Build Executable with PyInstaller (MacOS Zsh) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Installs PyInstaller and builds a single-file executable for imapbox.py on MacOS using zsh. Includes the VERSION file as data and specifies a custom icon. ```bash pip install --no-cache-dir pyinstaller pyinstaller --add-data "VERSION:." --onefile ./imapbox.py --icon ./resources/logo.icns ``` -------------------------------- ### imapbox Script Execution (Bash) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Command to execute the main imapbox Python script after successful local installation. It assumes that a configuration file named `config.cfg` is present in the current directory or a location specified in the script's logic. ```bash # usage # a config.cfg is expected as described above python ./imapbox/imapbox.py ``` -------------------------------- ### Searching imapbox Archive in a Specific Folder Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command combining `--local-folder` with `--search` to specify the directory where imapbox should look for archived emails before applying the search filter. ```bash imapbox --local-folder ./backups --search From,"user@domain.*" ``` -------------------------------- ### Saving imapbox Search Results to JSON File Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command using the `--search-output json` flag to format the search results as JSON and then redirecting the output to a `.json` file. This is useful for programmatic processing of search results. ```bash imapbox --search From,"user@domain.*" --search-output json > result.json ``` -------------------------------- ### Saving imapbox Search Results to Text File Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command demonstrating how to redirect the standard output of an imapbox search command to a text file using the shell's redirection operator `>`. The default output format is used. ```bash imapbox --search From,"user@domain.*" > result.txt ``` -------------------------------- ### Searching imapbox Archive by Body Content Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command using `imapbox --search` to find emails where the 'Body' field contains the text "some text". The `*` wildcards match any characters before and after the text. ```bash imapbox --search Body,"*some text*" ``` -------------------------------- ### Searching imapbox Archive by Boolean Property Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command using `imapbox --search` to find emails where the boolean property 'WithText' is true, indicating that a plain text version of the message body exists. ```bash imapbox --search WithText,True ``` -------------------------------- ### imapbox Docker Compose Configuration (YAML) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example YAML configuration for defining an imapbox service using Docker Compose. It specifies the Docker image to use, sets the container name, and configures volume mounts for persistent data storage and mounting a custom configuration file. ```yaml services: imapbox: image: bananaacid/imapbox:latest container_name: imapbox volumes: # use a docker volume, as backup location - imapbox_data:/var/imapbox # if you want to specify a specific folder as backup folder #- ./tmp/backup/:/var/imapbox/ # change the path './config.cfg' to the config # mounting files: an absolute path is always required #- ${PWD}/tmp/config.cfg:/etc/imapbox/config.cfg # # relative binding works fine - type: bind source: ./tmp/config.cfg target: /etc/imapbox/config.cfg volumes: imapbox_data: ``` -------------------------------- ### Searching imapbox Archive by Sender Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example command using `imapbox --search` to find emails where the 'From' field matches the fnmatch pattern "user@domain.*", effectively searching for emails from any user at 'domain' regardless of the top-level domain. ```bash imapbox --search From,"user@domain.*" ``` -------------------------------- ### imapbox Search JSON Output (Success) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example of the successful JSON output format when using the `--search-output json` option with imapbox. It includes filter details, a list of found items with metadata file paths and content, and the total count of items found. ```json { "filter": {"key": "WithText", "value": "True"}, "items": [ { "filename": "./INBOX/2024/...someid.../metadata.json", "content": { ... } // content of metadata file }, ... ], "found": 1 } ``` -------------------------------- ### imapbox Search JSON Output (Error) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Example of the JSON output format returned by imapbox when a search error occurs. It includes an error message, optional error details, the filter attempted, an empty items list, and a total count of 0. ```json { "error": 'Invalid search filter (`Keyword,"fnmatch syntax"`)', "error_details": "...", "filter": {}, "items": [], "total": 0 } ``` -------------------------------- ### Build and Push Docker Image to Docker Hub Source: https://github.com/bananaacid/imapbox/blob/master/README.md Logs into Docker Hub, builds the imapbox Docker image, tags it with both 'latest' and the version from the VERSION file, and pushes both tags to Docker Hub. ```bash docker login ``` ```bash docker build -t imapbox:latest . ``` ```bash docker tag imapbox:latest [USERNAME]/imapbox:$(cat VERSION) ``` ```bash docker tag imapbox:latest [USERNAME]/imapbox:latest ``` ```bash docker push [USERNAME]/imapbox:$(cat VERSION) ``` ```bash docker push [USERNAME]/imapbox:latest ``` -------------------------------- ### Generating DSN using imapbox Helper Source: https://github.com/bananaacid/imapbox/blob/master/README.md Shows the command to launch the interactive DSN helper provided by imapbox. This helper prompts the user for connection details and generates the corresponding DSN string. ```bash imapbox --input-dsn ``` -------------------------------- ### Using imapbox with Multiple DSNs Source: https://github.com/bananaacid/imapbox/blob/master/README.md Demonstrates how to use the imapbox command-line tool with multiple DSNs (Data Source Names) to fetch emails from different IMAP servers or specific folders. It shows how to specify local folder, force fetching, and use DSN parameters like `exclude_folder`. ```bash imapbox -l ./test -f --dsn imaps://username:password@imap.server.tld/INBOX,Sent --dsn imaps://username:password@imap.server2.tld/__ALL__?exclude_folder=Spam ``` -------------------------------- ### Creating Elasticsearch Index for imapbox Metadata Source: https://github.com/bananaacid/imapbox/blob/master/README.md Provides a `curl` command to create an Elasticsearch index named 'imapbox'. This index is intended to store the metadata extracted from emails by imapbox. ```bash curl -XPUT 'localhost:9200/imapbox?pretty' ``` -------------------------------- ### Adding imapbox Metadata to CouchDB Source: https://github.com/bananaacid/imapbox/blob/master/README.md Shows the `curl` command used within a loop (like the Elasticsearch script) to add an email's metadata (from `metadata.json`) as a document to a CouchDB database named 'imapbox'. The database must exist prior to running this command. ```bash curl curl -XPUT "localhost:5984/imapbox/${ID}" --data-binary "@${METADATAPATH}" ``` -------------------------------- ### Indexing imapbox Metadata into Elasticsearch Source: https://github.com/bananaacid/imapbox/blob/master/README.md A bash script that iterates through `metadata.json` files generated by imapbox in a local folder and uploads each one as a document to the 'imapbox' index in Elasticsearch using `curl`. It extracts the email ID from the file path. ```bash #!/bin/bash cd emails/ IFS=$'\n' for METADATAPATH in $(find . -name "metadata.json"); do subdir="${LINE%/metadata.json}" ID="${subdir##*/}" curl -XPUT "localhost:9200/imapbox/message/${ID}?pretty" --data-binary "@${METADATAPATH}" done ``` -------------------------------- ### imapbox Docker Cleanup (Bash) Source: https://github.com/bananaacid/imapbox/blob/master/README.md Command to remove the last generated imapbox container defined in the Docker Compose file. This is useful for cleaning up resources after the container has finished its execution. ```bash docker compose rm imapbox ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.