How to Setup and Configure tmpmail? Let’s discuss.
If we choose to stay within the command line for almost every role or purpose, tmpmail is a handy utility. It is a quick and easy method to create a temporary email address to use for incoming mail.
As part of our Server Management Services, we assist our customers with several Command-line queries.
Today, let us discuss the various aspects of tmpmail along with its setup and configuration.
How to Setup and Configure tmpmail
In order to begin, our Support Techs suggest having the following.
- w3m – A text-based web browser.
- wget or curl command.
- jq – A flexible, lightweight JSON processor for the command line.
To install w3m, wget, curl and jq in Arch Linux and Manjaro Linux, we run:
$ sudo pacman curl jq w3m wget
On Debian, Ubuntu and its derivatives:
$ sudo apt install curl wget jq w3m
Fedora, RHEL, CentOS:
$ sudo dnf install curl wget jq w3m
$ sudo dnf install curl wget jq w3m
Initially, we use the wget command or curl command to download the script from GitHub.
Then we open a terminal and copy or type in the following command:
[root@server ~]# wget https://raw.githubusercontent.com/sdushantha/tmpmail/master/tmpmail –2021-04-12 12:31:32– https://raw.githubusercontent.com/sdushantha/tmpmail/master/tmpmail Resolving raw.githubusercontent.com (raw.githubusercontent.com)… 220.127.116.11 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|18.104.22.168|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 12433 (12K) [text/plain] Saving to: ‘tmpmail.’ tmpmail 100%[=========================================>] 12.14K –.-KB/s in 0s 2021-04-12 12:31:32 (97.9 MB/s) – ‘tmpmail’ saved [12433/12433] [root@server ~]#
Now, to make the file executable we run the chmod command against the script to modify the permissions:
[root@server ~]# chmod -v +x tmpmail
Then, we will move the file to a location somewhere in our $PATH:
[root@server ~]# mv tmpmail /bin/ [root@server ~]# which tmpmail /usr/bin/tmpmail [root@server ~]#
The info from Help File provides a shortlist of how to use tmpmail.
To view the contents of the help file, we use the bl commands.
[root@server ~]# 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 inbox messages and their numeric IDs. When called with one argument, tmpmail shows the email message with the specified ID. -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. Without this option, HTML is used. –version Show version [root@server ~]#
- Generate a New tmpmail Address
We can create a new temporary email address via:
[root@server ~]# tmpmail –generate firstname.lastname@example.org [root@server ~]#
We can now use the email@example.com temporary email address to send and receive messages.
- Receive Email
To test this installation and its functionality, we send an email to the address above from a Gmail account.
After a few minutes of running the tmpmail command, we will receive this output:
[root@server ~]# tmpmail [ Inbox for firstname.lastname@example.org ] 105575154 email@example.com Tmpmail Test [root@server ~]#
In short, the email went through and was received by tmpmail. We can now view the email as raw text, where all the HTML tags are removed using:
[root@server ~]# tmpmail 105575154
Once we read the email, we hit ‘q,’ and then, when prompted, ‘Do you want to exit w3m? (y/n), hit ‘y’.
Eventually, the browser will close and return us to the command prompt.
- View Recent Email
If there are multiple emails, we can review the most recent one using:
[root@server ~]# tmpmail -r
If this gives numerous emails, we can rerun the tmpmail command to see a list of the current emails.
[root@server ~]# tmpmail [ Inbox for firstname.lastname@example.org ] 105576629 email@example.com Re: Tmpmail Test 105575154 firstname.lastname@example.org Tmpmail Test [root@server ~]#
- Change Browser Type
We can change the browser type to render the HTML of the email by running either of the two below:
[root@server ~]# tmpmail –browser lynx 105576629 [root@server ~]# tmpmail -b lynx 105576629
Additionally, if we have a browser like Firefox, we can use Firefox’s path to open the email.
[root@server ~]# tmpmail -b /usr/bin/firefox 105576629
- View Email in Plaintext
In addition, we can view the email in plaintext. For that, use the -t or –text flags to read the message.
[root@server ~]# tmpmail -t 105576629 [root@server ~]# tmpmail –text 105576629 To: email@example.com From: firstname.lastname@example.org Subject: Re: Tmpmail Test This is a 2nd test email. Regards, ===================== Bob John Bobcares Marketing Team On Mon, Apr 12, 2021 at 4:42 PM Bob John <email@example.com> wrote: Test1 Regards, ===================== Bob John Bobcares Marketing Team [root@server ~]#
On the other hand, let us see if the temp email can receive an attachment.
In this test, we create a new email from the Gmail account and attach a text file to see if it will provide a link to the file.
[root@server ~]# tmpmail [ Inbox for firstname.lastname@example.org ] 105578915 email@example.com Attachment Test Email 105576629 firstname.lastname@example.org Re: Tmpmail Test 105575154 email@example.com Tmpmail Test [root@server ~]#
From the output, we know we received the email.
Then we will look for the attachment:
[root@server ~]# tmpmail 105578915
Since there is no attachment in the w3m view, we check in plaintext view.
[root@server ~]# tmpmail -t 105578915 To: firstname.lastname@example.org From: email@example.com Subject: Attachment Test Email In this email, we created a text file, attached it and sent it to the tmpmail email address we created. Here ya go! Regards, ===================== Bob John Bobcares Marketing Team [root@server ~]#
The attachment was not seen here either.
In reviewing the API from 1secmail.com, the API can receive attachments. However, this script is not equipped to use that functionality.
Where Does the Domain Originate From?
Like other temporary email services (e.g., temp-mail.org, 10minutemail.com), the domain name is pulled from domains owned by 1secmail.
The email address generates via an API call from 1secmail.com and links to one of the following domains.
Using this method, we can generate an almost infinite number of email addresses across those five domains.
[Need help with the configuration? We can help you]
In short, tmpmail is a handy utility for CLI warriors within the command line. Today, we saw an effective method our Support Techs employ on how to Setup and Configure tmpmail.