Python Script for Disposable Email Addresses

You click on that button to download your FREE pdf and then a box pops up asking for your email: Where can I send the pdf

But, by giving your email, you know that along with your pdf you’ll be getting those “email updates”, you know what I mean…

 

So, what do you do to avoid the spam? You go over to mailinator.com, you get a disposable email address and you use that address for the opt-in above. Then, on the Mailinator website, you get an email with the pdf in your virtual inbox and let them send spam to Mailinator! In fact, those Mailinator mailboxes get deleted after a few hours, so all the future emails will hard bounce. I hope you got an idea what a disposable address is and why people use it.

OK, this is the story from the subscriber’s perspective. I understand there is so much spam out there and it’s fair that such websites as Mailinator exist. Each one of us has been in both the subscriber’s and sender’s position.

The way I look at this now is that if someone took the time to make a fake address just to download your free pdf means that they are expecting to get some value out of it which is great. I appreciate that and that’s a success itself. The thing is they don’t want to receive anything else from you right now apart from that pdf. Maybe they will like you so much and will want more from you later, but for now, that’s all.

If we look at it from the sender’s perspective, a sender has also a right to say “I don’t want your f&^&%&% disposable garbage in my list.” Fair enough.

So, for us poor senders that prefer tidy lists and hate bounces, I’ve just written a Python script for detecting the disposable email addresses. For this, I’ve used the awesome API from Kickbox.

Assumptions and notes: 

  1. I assume you have your emails in an excel file (.xls and NOT .csv) and particularly in the first sheet.
  2. I assume that the cell (1,1) doesn’t have an email address but a value like: “Emails”, “Email list”.
  3. The output results are saved in a new excel DisposableResults.xls file in your home directory with two columns. The first column contains the emails and the 2nd column a categorisation Disposable or OK. After you run the script, get rid of the disposable ones from your email list!
  4. If you have a question, please leave a comment!
# library for reading excel files
import xlrd 

# library for HTTP requests
import requests

# library for creating excel files
import xlwt

# library for parsing json files
import json

# This is a output excel file with the emails on the first column and the results of the script 
# on the second column - Disposable or OK
book = xlwt.Workbook()
newSheet1 = book.add_sheet("Emails")

# I assume you have an excel input file with all your email addresses in the first column and a title 
# like "Emails" in the cell(1,1).Replace the file location with the path of your excel input file

file_location = "/Users/Angelos/Desktop/Emails.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)

# The loop will run (number of rows) - 1 as the cell(1,1) doesn't have an email 
# but just a title: "Emails"
for row in range(sheet.nrows -1):
	email = sheet.cell_value(row + 1,0)
	newSheet1.write(row+1,0,sheet.cell_value(row + 1,0))
	
	# This is a valid http link that we can request from Kickbox API 
        # here https://open.kickbox.io/
	http_string = "https://open.kickbox.io/v1/disposable/" + sheet.cell_value(row + 1,0)

	# Request using the request library
	req = requests.get(http_string)
	
	# We load the request result into a json object
	parsed_json = json.loads(req.text)
	
	isDisposable = parsed_json['disposable']
	if isDisposable == True: 
		newSheet1.write(row+1,1,"Disposable")
	else:
		newSheet1.write(row+1,1,"OK")
	
# Save the output workbook with the name DisposableResults		
book.save('DisposableResults.xls')

 

You May also Like...

List Cleaning Secrets
January 31, 2018
Interview with Adobe Deliverability Expert Jon Burke
February 2, 2018
How to Increase Email Deliverability – Complete Action List
January 29, 2018

Leave a Reply

Your email address will not be published. Required fields are marked *