Home » Social Media » Email-Marketing » Create unique, sorted email list from all subscriber emails

Create unique, sorted email list from all subscriber emails

As you might be knowing Email marketing is best, effective and cheapest way to reach your customers to increase your sale. But the side effects of email marketing is lots of wastage of emails if your email list is not optimised to identify only active emails so as you can save money required send lots of emails, which some people may not open also.

Also, there are chances that when people enter their email id’s during subscription on your website, they may enter their email id’s will spelling mistakes, duplicated email subscriptions or wrong domain names in email id which tends to bounce the emails sent to this email ids, hence as our email list matures we have to remove those bounced email ids or email ids which people unsubscribes after seeing our marketing emails but are not interested into our future emails.

$ vim create_optimised_email_list.sh
sort -u all-exported-emails.txt > unique_emails.txt

rm -rf final_optimised_email_list.txt

while read line

#remove unwanted character from email
if [ "$NEW_MAIL" == "${NEW_MAIL//[\,\' ]/}" ]
        check=$(grep -r $NEW_MAIL unsubscribed_emails.txt)
        if [ "$check" =  "$NEW_MAIL" ]; then
                echo "email $NEW_MAIL found in unsubscribed_emails.txt"
                check2=$(grep -r $NEW_MAIL bounced_emails.txt)
                if [ "$check" =  "$NEW_MAIL" ]; then
                        echo "email $NEW_MAIL found in bounced_emails.txt"
                        echo $NEW_MAIL >> final_optimised_email_list.txt
   echo "email $NEW_MAIL contains space, comma or quote.. hence ignoring"

done < unique_emails.txt

This script can be run as below and it will create the final unique list of emails in new text file final_optimised_email_list.txt

$ bash create_optimised_email_list.sh 

The above script accepts following text files as described,

  • all-exported-emails.txt – This is the text file with all email ids as subscribed by the users with single email id every line.
  • unique_emails.txt – This text file will get generated after we run unique sort command to skip all duplicated email ids and sort them.
  • unsubscribed_emails.txt – This file contains list of unsubscribed email ids.
  • bounced_emails.txt – This file contains bounced email ids, so that we skip the emails from the final email list.
  • final_optimised_email_list.txt – This is final email list with all invalid email ids removed, all unsubscribed and bounced email ids also removed from final list.

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment