Generating New Email Addresses for new services
I wrote a little script recently to generate new email addresses using the CloudFlare API.
By doing this, I can create loads of email addresses really quickly and set up disposable ones for new services or categories of services. The script either randomly generates an identifier, or will use a value provided as input.
A nice next step would be to integrate this with a password manager, and generate the email and password at the same time.
I've been using this while looking for an apartment. Signing up to anything real-estate related will result in you receiving a deluge of spam. While I'm looking for the apartment I do want the spam (at least some of it!), but I want to be able to turn off the fire hose once I have found an apartment.
If I recall correctly, Yahoo used to provide a free service that did this kind of thing.
Anyway, here is the script:
#!/bin/bash
apikey='apikey-goes-here000000000000000000000000'
zone_identifier='zone-identifier-goes-here0000000'
url="https://api.cloudflare.com/client/v4/zones/${zone_identifier}/email/routing/rules"
if [ $# -gt 0 ] ; then
addr="[email protected]"
else
addr="$(openssl rand -hex 32 | head -c 8)@danrh.net"
fi
curl "$url" \
--data-raw '{
"enabled":true,
"name": "Rule created at '"$(date -u +'%Y-%m-%dT%H:%M:%S.000Z')"'",
"actions":[{"type":"forward","value":["[email protected]"]}],
"matchers":[{"type":"literal","field":"to","value":"'"$addr"'"}]
}' \
-H "Authorization: Bearer $apikey" \
-H 'content-type: application/json'