Giter Club home page Giter Club logo

tmpmail's Introduction

A temporary email right from your terminal written in POSIX sh


tmpmail is a command line utility written in POSIX sh that allows you to create a temporary email address and receive emails to the temporary email address. It uses 1secmail's API to receive emails.

By default w3m is used to render the HTML emails on the terminal. But if you prefer another text based web browser or would rather view the email in a GUI web browser such as Firefox, simply use the --browser argument followed by the command needed to launch the web browser of your choice.




Dependencies

  • w3m
  • curl
  • jq
  • xclip

Installation

Install locally

# Download the tmpmail file and make it executable
$ curl -L "https://raw.githubusercontent.com/sdushantha/tmpmail/master/tmpmail" > tmpmail && chmod +x tmpmail

# Then move it somewhere in your $PATH. Here is an example:
$ mv tmpmail ~/bin/

AUR

tmpmail is available on the AUR, which is currently being maintained by Benjamin Bädorf

$ yay -S tmpmail-git

Pacstall (Debian/Ubuntu)

tmpmail is available on the pacstall-programs repository, which is being currently being maintained by wizard-28

$ pacstall -I tmpmail-bin

Nixpkgs

tmpmail is also available in the nix package collection (only unstable currently), which is maintained by legendofmiracles

Either add it to your system packages, install it with nix-env or try it out in a ephemeral nix-shell nix-shell -p tmpmail

Docker

requirements:

$ docker build -t mail .; # Dockerfile available in source code
$ docker run -it mail;

Usage

$ tmpmail --help
tmpmail
tmpmail -h | --version
tmpmail -g [ADDRESS]
tmpmail [-t | -b BROWSER] -r | ID

When called with no option and no argument, tmpmail lists the messages in
the inbox and their numeric IDs.  When called with one argument, tmpmail
shows the email message with specified ID.

-b, --browser BROWSER
        Specify BROWSER that is used to render the HTML of
        the email (default: w3m)
    --clipboard-cmd COMMAND
        Specify the COMMAND to use for copying the email address to your
        clipboard (default: xclip -selection c)
-c, --copy
        Copy the email address to your clipboard
-d, --domains
        Show list of available domains
-g, --generate [ADDRESS]
        Generate a new email address, either the specified ADDRESS, or
        randomly create one
-h, --help
        Show help
-r, --recent
        View the most recent email message
-t, --text
        View the email as raw text, where all the HTML tags are removed.
        Without this option, HTML is used.
--version
        Show version

Examples

Create random email

$ tmpmail --generate
[email protected]

Create custom email

View the inbox

$ tmpmail
[ Inbox for [email protected] ]

83414443   [email protected]   Test Email

View the email

$ tmpmail 83414443

View the most recent email

$ tmpmail -r

View emails as pure text

$ tmpmail -t 83414443
To: [email protected]
From: [email protected]
Subject: Test Email

Hello World

[Attachments]
https://is.gd/aBCdEf [apple.jpg]
https://is.gd/AbCDeF [ball.jpg]

Credits

This script is heavily inspired by Mitch Weaver's 1secmail script

tmpmail's People

Contributors

abaldwin-op avatar aincube avatar androiddevnotes avatar avil13 avatar bleuenvert avatar diggajupadhyay avatar jschauma avatar kevcui avatar legendofmiracles avatar leonklingele avatar mehtaarn000 avatar renbaoshuo avatar rjhbrunt avatar sandr01d avatar sdushantha avatar victorlpgazolli avatar vladimyr avatar wizard-28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmpmail's Issues

allow passing username to generate function

Hi, thanks a lot for tmpmail. It's a breeze to use. 😉

Perhaps we could pass an argument to the generation function in order to access an inbox for an email we created in the past? let's say, a login for a forum

tmpmail --generate foobar
[ Inbox for [email protected] ] 

At the moment I am editing the /tmp/tmpmail/email_address file to set it up.
I appreciate its good practice to keep those usernames random and unidentifiable but it's just in case you need to recover a password for a service or get any timely notification.

Emails with multibyte chars not appearing due to column

Sent myself an email with the subject text containing the char "ê".

./tmpmail
[ Inbox for [email protected] ]

column: Invalid or incomplete multibyte or wide character

The email is then unreadable as well.

If you only include those especial characters in the email body then i can be read

./tmpmail -t -r
column: Invalid or incomplete multibyte or wide character
To: [email protected]
From: [email protected]
Subject: aaaee

aaa?eeeeeee

where the ?='ê'

integer expression expected

I keep having this errors, never had this in previous versions.
Any help please?

/usr/local/bin/tmpmail: line 198: [: : integer expression expected
/usr/local/bin/tmpmail: line 206: [: : integer expression expected

Thanks in advance.

Checking on the command syntax before changing the options/arguments code.

I think that I can make improvements to the code that processes the arguments and options, both in terms of clarity/brevity as well as robustness (e.g. error checking for optional arguments). I did a code change earlier that changed the syntax of the command, which was declined. Before I do another change, I want to double check on the current syntax and semantics of the command. This is my interpretation of how the command currently (or is supposed to) works. Is it accurate? Note that this is the output of a manpage that I wrote, and following manpage conventions, the brackets indicate optional and the pipe indicates xor.

NAME
     tmpmail — temporary mail

SYNOPSIS
     tmpmail
     tmpmail -h | --version
     tmpmail -g [ADDRESS]
     tmpmail [-t | -b BROWSER] -r | ID

OPTIONS
     -b | --browser BROWSER
             Specify BROWSER (default: w3m) that is used to render the HTML of
             the email

     -g | --generate [ADDRESS]
             Generate a new email address, either the specified ADDRESS, or
             randomly create one

     -h | --help
             Show help

     -r | --recent
             View the most recent email message

     -t | --text
             View the email as raw text, where all the HTML tags are removed
             (default: html)

     --version
             Show version

ARGUMENTS
     When called with no option and no argument, tmpmail lists the messages in
     the inbox and their numeric IDs.  When called with one argument, tmpmail
     shows the email message with specified ID.

Slashes duplicated twice

tmpmail/tmpmail

Lines 25 to 31 in b65d55b

TMPMAIL_DIR="/tmp/tmpmail/"
# TMPMAIL_EMAIL_ADDRESS is where we store the temporary email address
# that gets generated. This prevents the user from providing
# the email address everytime they run tmpmail
TMPMAIL_EMAIL_ADDRESS="$TMPMAIL_DIR/email_address"
TMPMAIL_HTML_EMAIL="$TMPMAIL_DIR/tmpmail.html"

Should be

TMPMAIL_DIR="/tmp/tmpmail"

# TMPMAIL_EMAIL_ADDRESS is where we store the temporary email address 
# that gets generated. This prevents the user from providing  
# the email address everytime they run tmpmail 
TMPMAIL_EMAIL_ADDRESS="$TMPMAIL_DIR/email_address"
TMPMAIL_HTML_EMAIL="$TMPMAIL_DIR/tmpmail.html"

tag releases

Hey! I packaged tmpmail for nixpkgs a while back, but just noticed that you also update this project more often and even release versions.
Unfortunately I cannot seem to find the appropriate tags for each version, which would make packaging - updating and maintaing the package a lot easier in nixpkgs

Cheers

An option to copy email address to clipboard

Currently, for copy the email address, it needs to be done manually. That is,
Run tmpmail then select and copy.

But it'd be quite helpful if an option could copy the address to clipboard by xclip on X and wl-clipboard on Wayland.

Like -c or --copy-adress

Thanks (:

Generate address and paste it into clipboard?

Would it not be useful to generate an address, and paste it into the clipboard with a flag?

I tried it with tmpmail -g | xclip but it doens't oddly seem to work. Perhaps mpmail -g -cas extra flag to paste into a clipboard (with-c` flag)?

Cannnot open emails.

I'm currently using WSL with Ubuntu on Windows 10, when typing in ./tmpmail, I get the expected result, but when I type in ./tmpmail [ID OF MAIL], I get the following error:

Wrong __data_start/_end pair
Aborted (core dumped)

name generation error

image

OS: MacOS

Hi. There is an error when generating a username.
I suggest replacing the username method.

$(date +%s | base64 | tr -dc '[[:alnum:]]' | tr '[:upper:]' '[:lower:]')

Request for Pacstall Support

Pacstall is a community-driven AUR-like package manager for Ubuntu. We have an ongoing pull request to add tmpmail to our repository.

We have a few questions for you:

  • Would you like to maintain the pacscript (similar to a PKGBUILD) yourself? We can maintain it for you if you decide not to.
  • Could you include a section in your documentation showing Pacstall as a valid method of installation for tmpmail for Debian/Ubuntu users? We could make a pull request for that if you want.

Enable TLD selection

The provider 1secmail.com offers several TLDs for its service, I would also like to have this selection in the CLI.
Thanks a lot

add support for other clipboard

I have just installed and run the command tmpmail but it is reporting that the missing dependencies for xclip

I am thinking if it is possible to allow for other clipboard such as wl-copy for wayland?

Is it possible to use another API with doing no change on script?

Hi!

1secmail service doesn't seem to be working very well, at least for me. It most of the time works but it has frequent down times. Was this script designed only for 1secmail's api or is there any other service it supports, or reported working with this script?

body is not shown for plaintext mails

If an email is only sent as plaintext the script does not show the output because the body is delivered in a different field.

{
	"id": 639,
	"from": "[email protected]",
	"subject": "Some subject",
	"date": "2018-06-08 14:33:55",
	"attachments": [{
		"filename": "iometer.pdf",
		"contentType": "application\/pdf",
		"size": 47412
	}],
	"body": "Some message body\n\n",
	"textBody": "Some message body\n\n",
	"htmlBody": ""
}

See section Fetching single message under https://www.1secmail.com/api/

Version number discrepancy

FYI, the latest version number shown on Github is 1.1.4, but the version shown in the tmpmail file itself is 1.1.9.

"tr: Illegal byte sequence" on FreeBSD

Hi,

the following line:

USERNAME=$(head /dev/urandom | tr -dc a-z | cut -c1-11)

returns the following error on FreeBSD:

tr: Illegal byte sequence

and no valid e-mail address can be generated.
I suggest to add the following line at the top of the script:

export LC_ALL=C

Thanks for the nice tool,
regards,
Riccardo

shuf is not POSIX-compliant

You are using shuf which is not POSIX-compliant.

I found an answer/solution on stackoverflow.

It seems that the proposed solution is not the most performant, but because you are shuffling only 5 values, that shouldn't be a problem.

Error message

Hello,

I'm MB. A very nice and polite guy.

Here is an error message I'm getting. Any way to work around it?

mkdir: cannot create directory ‘/tmp’: Read-only file system ./tmpmail: 130: cannot create /tmp/tmpmail/email_address: Directory nonexistent
head: cannot open '/tmp/tmpmail/email_address' for reading: No such file or directory

Python CLI and Module - pydispo

Not exactly an issue, but reporting an additional feature/enhancement.
Inspired by tmpmail, I have written a kind of pure-pythonic utility to perform similar tasks. Its called pydispo and you can find it at https://github.com/aakash30jan/pydispo. I have tried making it platform-independent and almost without external dependencies, but tried keeping the similar usage pattern as tmpmail.
Thanks @sdushantha , I have already cited tmpmail on my repo.

Unknown release commit

I'm maintaining AUR package for tmpmail (link) and I've come across a small problem. The latest release (tag v1.2.0) points to a commit 3ba416b, however the version number in the source was not changed until ec2d321. I can also see that copying of the email address was introduced in b28789b as well as bumping the version number once again. I'm not sure which one should be used and weather this was deliberate or a mistake.

Thanks in advance!

New line

For some reason when I generate new email, tmpmail doesn't output new line and my terminal is messed up:

Screenshot 2021-01-11 at 20 06 37

Email disappear!

How long the received email will stay on the 1secmail server?
I noticed that after a bit is not present anymore. Would be good to know how long will be available.
Thanks

Allow command line flags to be used in any order

At the moment the flags have to be in a certain order.
For example if I want to view the most recent email and want the output to be as raw text, I have to run tmpmail --text --recent for it work properly. Running tmpmail --recent --text will ignore the --text flag.

By allowing the flags to be used in any order would make it much easier to use.

Could not resolve host: raw.githubusercontent.com

I cant install it:

gCs-MacBook-Pro:~ gc$ curl -L "https://git.io/tmpmail" > tmpmail && chmod +x tmpmail
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:21 --:--:-- 0
curl: (6) Could not resolve host: raw.githubusercontent.com

Any help please?
Thank you in advance.

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.