Git Product home page Git Product logo

mailbox-org-cli's Introduction

joelpet/mailbox-org-cli

Unoffical command line "client" for managing mailbox.org disposable addresses.

TBH it's hard to call it client - it does not use API for achieve its goals, as there is no API for that feature.

What it does it pretends to be browser and interacts with management panel in good-old form-based way.

Installation

If you have Go installed, you can either:

  • install it from source go install github.com/joelpet/mailbox-org-cli@latest
  • clone repository and build it by yourself: go build . (requires Go 1.17)

Usage

Command line "client" for mailbox.org disposable addresses feature
mailbox-org-cli 0.1.0
Usage: mailbox-org-cli --username USERNAME [--password PASSWORD] [--password-on-stdin] <command> [<args>]

Options:
  --username USERNAME    mailbox.org username [env: MAILBOX_ORG_USERNAME]
  --password PASSWORD    mailbox.org password [env: MAILBOX_ORG_PASSWORD]
  --password-on-stdin    read password from stdin
  --help, -h             display this help and exit
  --version              display version and exit

Commands:
  list                   list disposable addresses
  renew                  renew disposable address
  delete                 delete disposable address
  set-memo               set-memo on existing disposable address
  create                 create new disposable address with optional memo

Here is an example how you can use this command with password manager:

$ pass Email/mailbox.org | mailbox-org-cli --username [email protected] --password-on-stdin list

[
  {
    "email": "[email protected]",
    "memo": "foo bar",
    "expires": "2022-02-28"
  },
  {
    "email": "[email protected]",
    "memo": "", # there's no memo set
    "expires": "2022-03-31"
  }
]

All output is JSON, so you will probably need something like jq to extract specific data. Using example output above this command will copy first item's email into clipboard (wl-copy on Wayland):

mailbox-org-cli ... list | jq --raw '.[0].email' | wl-copy

Possible use cases

  • mailbox.org's disposable addresses have expiry date. But can be extended as many times as required. So if you want to have "permanent" address, just set cron every, lets say, 2 weeks with mailbox-org-cli renew.
  • as this is CLI tool, you can easily integrate it with some launcher like Alfred
  • ...your idea :)

Design decisions

  1. Why it's in Go instead of JS/Python/PHP/other-scripting-language ?

The original author based the first version on JS, but then they realized that they wanted single binary which can be run on scratch, without any JS, Python, PHP, Ruby, etc interpreter installed.

  1. Why there are no tests?

Because of how surf works, it's hard to "feed" it with stubbed HTML content. Other solutions include using some HTTP mocking library or setuping some local mock server. Manual testing will suffice for now.

  1. Why does it use username/password instead of token?

Becasue the original author didn't find a way to generate application token in Mailbox.org interface. Official API also requires username/password and gives you token which is valid only for 20 minutes.

One could probably use PHPSESSID but extracting this requires you either to dig into browser's Dev Tools or CLI tool should store it somewhere after first login.

Due to the fact that this tool isn't making dozens of API requests in one call and how fast login process is, ATM username/password is the way to go.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.