|
@@ -59,6 +59,8 @@ shows the email message with specified ID.
|
|
|
clipboard (default: xclip -selection c)
|
|
clipboard (default: xclip -selection c)
|
|
|
-c, --copy
|
|
-c, --copy
|
|
|
Copy the email address to your clipboard
|
|
Copy the email address to your clipboard
|
|
|
|
|
+-d, --domains
|
|
|
|
|
+ Show list of available domains
|
|
|
-g, --generate [ADDRESS]
|
|
-g, --generate [ADDRESS]
|
|
|
Generate a new email address, either the specified ADDRESS, or
|
|
Generate a new email address, either the specified ADDRESS, or
|
|
|
randomly create one
|
|
randomly create one
|
|
@@ -74,6 +76,28 @@ shows the email message with specified ID.
|
|
|
EOF
|
|
EOF
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+get_list_of_domains() {
|
|
|
|
|
+ # Getting domains list from 1secmail API
|
|
|
|
|
+ data=$(curl -sL "$tmpmail_api_url?action=getDomainList")
|
|
|
|
|
+
|
|
|
|
|
+ # Number of available domains
|
|
|
|
|
+ data_length=$(printf %s "$data" | jq length)
|
|
|
|
|
+
|
|
|
|
|
+ # If the length of the data we got is 0, that means the email address
|
|
|
|
|
+ # has not received any emails yet.
|
|
|
|
|
+ [ "$data_length" -eq 0 ] && echo "1secmail API error for getting domains list" && exit
|
|
|
|
|
+
|
|
|
|
|
+ # Getting rid of quotes, braces and replace comma with space
|
|
|
|
|
+ printf "%s" "$data" | tr -d "[|]|\"" | tr "," " "
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+show_list_of_domains() {
|
|
|
|
|
+ # Convert the list of domains which are in a singal line, into multiple lines
|
|
|
|
|
+ # with a dash in the beginning of each domain for a clean output
|
|
|
|
|
+ domains=$(printf "%s" "$(get_list_of_domains)" | tr " " "\n" | sed "s/^/- /g")
|
|
|
|
|
+ printf "List of available domains: \n%s\n" "$domains"
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
generate_email_address() {
|
|
generate_email_address() {
|
|
|
# There are 2 ways which this function is called in this script.
|
|
# There are 2 ways which this function is called in this script.
|
|
|
# [1] The user wants to generate a new email and runs 'tmpmail --generate'
|
|
# [1] The user wants to generate a new email and runs 'tmpmail --generate'
|
|
@@ -107,10 +131,10 @@ generate_email_address() {
|
|
|
# the first 10 characters, which will be the username of the email address
|
|
# the first 10 characters, which will be the username of the email address
|
|
|
username=$(head /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | cut -c1-11 | tr "[:upper:]" "[:lower:]")
|
|
username=$(head /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | cut -c1-11 | tr "[:upper:]" "[:lower:]")
|
|
|
|
|
|
|
|
- valid_email_address_regex="[a-z0-9]+@(1secmail\.(com|net|org)|esiix.co|wwjmp.com|xojxe.com|yoggm.com)"
|
|
|
|
|
|
|
+ # Generate a regex for valif email adress by fetching the list of supported domains
|
|
|
|
|
+ valid_email_address_regex=$(printf "[a-z0-9]+@%s" "$(get_list_of_domains | tr ' ' '|')")
|
|
|
username_black_list_regex="(abuse|webmaster|contact|postmaster|hostmaster|admin)"
|
|
username_black_list_regex="(abuse|webmaster|contact|postmaster|hostmaster|admin)"
|
|
|
username_black_list="- abuse\n- webmaster\n- contact\n- postmaster\n- hostmaster\n- admin"
|
|
username_black_list="- abuse\n- webmaster\n- contact\n- postmaster\n- hostmaster\n- admin"
|
|
|
- domains="1secmail.com 1secmail.net 1secmail.org esiix.com wwjmp.com xojxe.com yoggm.com"
|
|
|
|
|
|
|
|
|
|
# Randomly pick one of the domains mentioned above.
|
|
# Randomly pick one of the domains mentioned above.
|
|
|
domain=$(printf "%b" "$domains" | tr " " "\n" | randomize | tail -1)
|
|
domain=$(printf "%b" "$domains" | tr " " "\n" | randomize | tail -1)
|
|
@@ -356,6 +380,7 @@ main() {
|
|
|
while [ "$1" ]; do
|
|
while [ "$1" ]; do
|
|
|
case "$1" in
|
|
case "$1" in
|
|
|
--help | -h) usage && exit ;;
|
|
--help | -h) usage && exit ;;
|
|
|
|
|
+ --domains | -d) show_list_of_domains && exit ;;
|
|
|
--generate | -g) generate_email_address true "$2" && exit ;;
|
|
--generate | -g) generate_email_address true "$2" && exit ;;
|
|
|
--clipboard-cmd) copy_to_clipboard_cmd="$2" ;;
|
|
--clipboard-cmd) copy_to_clipboard_cmd="$2" ;;
|
|
|
--copy | -c) copy_email_to_clipboard && exit ;;
|
|
--copy | -c) copy_email_to_clipboard && exit ;;
|