Giving Out Your Email Address
Most people are generally aware that giving out his/her email address openly on the Internet is a bad idea. Spammers will flood your inbox with unwanted spam and scam messages. Hackers will send you viruses and malware. Once your email address is out, it is a sure bet it will be passed around the Internet among unscrupulous people.
121mailer.com provides a way for users to protect their private email addresses. A user never has to give out his/her real email address. Instead, 121mailer.com generates a random and unique email address for each contact you wish to communicate with. Any messages sent to the unique email address are forwarded to you. Replies you send are routed through 121mailer.com, at which point your private email address is replaced and protected.
Publishing Your Email
Besides allowing you to generate unique email addresses manually via a user interface, 121mailer.com also provides an Internet API to create and publish email addresses. This API can be used on a web page with JavaScript to dynamically generate random and unique email addresses. We use a simple example here to let you email us.
Send us a message:
Below is the API documentation along with examples of its use on web pages.
Email Address Creation API
The API is hosted on an HTTP server at the URL: https://121mailer.com/reqemail.php. Calling this API requires an HTTP POST request with the "Content-Type"" set to "application/x-www-form-urlencoded". Two parameters are required in the API call: a user id and a CAPTCHA response.
The user id is a string that identifies the account for which an email address is being generated. It is shown at the top of the web page after a user has been logged in. A CAPTCHA response is required in order to prevent bots or scripts from overloading the API. The hCaptcha system is used by 121mailer.com to verify human interaction. Refer to documentation on docs.hcaptcha.com for details of calling this API. The following hCaptcha sitekey associated with 121mailer.com must be used for the human verification step. The response data from this step is then used as a parameter in the API call to generate an email address.
sitekey: 1ecd1943-9dc5-47d2-848d-9b28170e1a05
The results of the API call to /reqemail.php are returned as a JSON string. The "success" { "success": true, ... } object returns "true" if the call is OK or "false" if it failed. The "email" { ..., "email": "xxx@121mailer.com" } objects returns an email address if the call succeeded.
POST parameter | Description |
---|---|
user | User ID |
response | h-captcha-response data from verification step |
sender (optional) | the sender email address associated with the unique email |
Object Name | Description |
---|---|
success | true | false (success or failure) |
(if success) string data for email address | |
useby | (optional) Unix time integer for expiration of email address if not used |
error | (if failure) error message describing failure reason |
Example #1
This is a simple example of a web page with JavaScript code that calls the /reqemail.php email creation API on 121mailer.com. It uses a "button" element declared with "h-captcha" class. It specifies the sitekey associated with 121mailer.com, which is required. The hCaptcha JavaScript library takes control of the button's onclick event to perform the human verification step.
<button class="h-captcha" data-callback="captchaResponse" ... >The verification response data is passed back to our custom callback JavaScript function. The callback function then constructs the parameters for an API call to /reqemail.php. The example code below passes user id and verification response data as parameters.
function captchaResponse(responseToken) { ... var xhr = new XMLHttpRequest(); xhr.open("POST", url); ... xhr.send("user=" + userID + "&response=" + responseToken); }
When the HTTP API returns with its results, another callback function exacts the JSON string into a JavaScript object. If the operation is successful, the email address is written to an HTML element and displayed on the web page.
Refer to the standalone web page for Example #1 and review its underlying JavaScript source for details.
Example #2
This example expands Example #1 to add handling for an expiration time to the returned email address. The server may use an expiration to improve processing efficiency. If a generated email address has not been used to send or receive email messages after a certain period of time, it may be deleted on the server. If an email address has been used, it no longer has an expiration time.
if ("useby" in resultObj) { const dt = new Date(resultObj.useby * 1000); ... usebyElem.innerHTML = " (Use By: " + dt.toLocaleString() + ")"; ... }The time string is in Unix time in seconds. The sample code converts it to local time zone and display format on the client's browser.
Refer to the standalone web page for Example #2 and review its underlying JavaScript source for details.
Example #3
This example expands Example #2 to associate a sender email address to the randomly generated email address. The generated email address will only forward messages with the specified sender address. If an existing email address already exists for the same sender, that address is returned.
The sample code retrieves the sender email address via a form input and calls the hCaptcha API manually.
hcaptcha.execute();The response data from the verification step is sent to the /reqemail.php API along with the sender email address.
const fromElem = document.getElementById("your_emailaddress"); xhr.send("user=" + userID + "&response=" + responseToken + "&sender=" + fromElem.value);
Refer to the standalone web page for Example #3 and review its underlying JavaScript source for details.
Putting It Together
An easy way to experiment with the email address generator on your web page is to try Example #1 on your web server. The example is minimalist and tries to shows the basic code necessary. You can replace just the user id with one belonging to your account to make it work.
const userID = "...your id...";You can then move the working code fragments into your own web page.
To try the /reqemail.php API on the command line. You could use the curl command as shown below. The "rdata" file is assumed to contain the response token received from the hCaptcha verification.
curl https://121mailer.com/reqemail.php \ -X POST --data-urlencode "response@rtoken" \ -d "user=your_user_id"A successful call may return a JSON string similiar to the following:
{ "success": true, "email": "z036l02drvsabgtnhca0g@121mailer.com", "useby": 1649077522 }