Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

remove dependency on pydns

  • Loading branch information...
commit 841511a0e6ad4ce65d98e51a338f658f0e40b506 1 parent 0b79082
Val Neekman authored
5 HISTORY
... ... @@ -1,4 +1,9 @@
1 1
  2 +- Sept 17, 2012 (v 0.1)
  3 +------------------------
  4 +1. Remove dependency on external packages (pydns)
  5 +
  6 +
2 7 - Sept 16, 2012 (v 0.1)
3 8 ------------------------
4 9 1. Initial release
4 emailahoy/__init__.py
... ... @@ -1,10 +1,10 @@
1 1 # -*- coding: utf-8 -*-
2 2
3 3 import sys
4   -import DNS
5 4 import smtplib
6 5 import socket
7 6 import re
  7 +from utils import query_mx
8 8
9 9 # only allow the import of our public APIs (UU-SLUG = Uniqure & Unicode Slug)
10 10 __all__ = ['VerifyEmail', 'verify_email_address']
@@ -21,7 +21,7 @@ def get_mx_for_hostname(self, hostname):
21 21 mx = []
22 22 if self.is_hostname_valid(hostname):
23 23 try:
24   - mx = DNS.mxlookup(hostname)
  24 + mx = query_mx(hostname)
25 25 except:
26 26 pass
27 27 return mx
26 emailahoy/utils.py
... ... @@ -0,0 +1,26 @@
  1 +import popen2
  2 +import re
  3 +
  4 +mx_re = re.compile('mail\sexchanger\s=\s(\d+)\s(.*)\.')
  5 +
  6 +def query_mx(host):
  7 + mx = []
  8 + addr = {}
  9 + fout, fin = popen2.popen2('which nslookup')
  10 + cmd = fout.readline().strip()
  11 + if cmd <> '':
  12 + fout, fin = popen2.popen2('%s -query=mx %s' % (cmd, host))
  13 + line = fout.readline()
  14 + while line <> '':
  15 + m = mx_re.search(line.lower())
  16 + if m:
  17 + mx.append((eval(m.group(1)), m.group(2)))
  18 + line = fout.readline()
  19 +
  20 + if mx:
  21 + mx.sort()
  22 + return mx
  23 +
  24 +#
  25 +# if __name__ == "__main__":
  26 +# print query_mx('google.com')
1  setup.py
@@ -12,7 +12,6 @@ def read(fname):
12 12 author_email='val@neekware.com',
13 13 url='http://github.com/un33k/python-emailahoy',
14 14 packages=['emailahoy'],
15   - install_requires = ['pydns', ],
16 15 classifiers = [
17 16 'Development Status :: 4 - Beta',
18 17 'Intended Audience :: Developers',

0 comments on commit 841511a

Please sign in to comment.
Something went wrong with that request. Please try again.