def test_lookupMailExchange(self): """ See L{test_lookupAddress} """ d = client.lookupMailExchange(self.hostname) d.addCallback(self.checkResult, dns.MX) return d
def send_device(uuid): if os.path.isdir(os.path.join(tmpdir,uuid)) == 1: tgz_file_name = os.path.join(tmpdir,uuid+'.tgz') cwd = os.getcwd() os.chdir(tmpdir) import tarfile tar = tarfile.open(tgz_file_name, "w:gz") for file in os.listdir(os.path.join(tmpdir,uuid)): tar.add(os.path.join(uuid,file)) tar.close() os.chdir(cwd) def got_mx(result): mx_list = result[0] mx_list.sort(lambda x, y: cmp(x.payload.preference, y.payload.preference)) if len(mx_list) > 0: import socket import getpass # from_address = '@'.join((getpass.getuser(),socket.gethostname())) reactor.connectTCP(str(mx_list[0].payload.name), 25, SMTPClientFactory(from_address, email_address, 'xml-files', tgz_file_name)) mx = namesclient.lookupMailExchange(mail_domain) mx.addCallback(got_mx)
def cmd_send(self, args): "send <uuid> -- send before extracted xml files to the Coherence home base" if os.path.isdir(os.path.join('/tmp', args[0])) == 1: cwd = os.getcwd() os.chdir('/tmp') import tarfile tar = tarfile.open(os.path.join('/tmp', args[0] + '.tgz'), "w:gz") for file in os.listdir(os.path.join('/tmp', args[0])): tar.add(os.path.join(args[0], file)) tar.close() os.chdir(cwd) def got_mx(result): mx_list = result[0] mx_list.sort(lambda x, y: cmp(x.payload.preference, y.payload. preference)) if len(mx_list) > 0: import posix import pwd import socket reactor.connectTCP( str(mx_list[0].payload.name), 25, SMTPClientFactory( '@'.join((pwd.getpwuid(posix.getuid())[0], socket.gethostname())), '*****@*****.**', 'xml-files', os.path.join('/tmp', args[0] + '.tgz'))) mx = namesclient.lookupMailExchange('googlemail.com') mx.addCallback(got_mx)
def mx(domain): """ Return list of MX domains for a given domain. """ from twisted.names.client import lookupMailExchange def got_records(result): hosts, authorities, additional = result return [str(record.name) for record in additional] d = lookupMailExchange(domain) d.addCallback(got_records) return d
def _mx(domain): """ Return Deferred that fires with a list of (priority, MX domain) tuples for a given domain. """ def got_records(result): return sorted([(int(record.payload.preference), str(record.payload.name)) for record in result[0]]) d = lookupMailExchange(domain) d.addCallback(got_records) return d
def _mx(domain): """ Return Defered that fires with a list of (priority, MX domain) tuples for a given domain. """ def got_records(result): return sorted([(int(record.payload.preference), str(record.payload.name)) for record in result[0]]) d = lookupMailExchange(domain) d.addCallback(got_records) return d
def send_email(self, file): def got_mx(result): mx_list = result[0] mx_list.sort(lambda x, y: cmp(x.payload.preference, y.payload.preference)) if len(mx_list) > 0: import posix, pwd import socket from twisted.internet import reactor reactor.connectTCP(str(mx_list[0].payload.name), 25, SMTPClientFactory('@'.join((pwd.getpwuid(posix.getuid())[0],socket.gethostname())), EMAIL_RECIPIENT, 'xml-files', file)) mx = namesclient.lookupMailExchange('googlemail.com') mx.addCallback(got_mx)
def send_email(self, file): def got_mx(result): mx_list = result[0] mx_list.sort( lambda x, y: cmp(x.payload.preference, y.payload.preference)) if len(mx_list) > 0: import posix, pwd import socket from twisted.internet import reactor reactor.connectTCP( str(mx_list[0].payload.name), 25, SMTPClientFactory( '@'.join((pwd.getpwuid(posix.getuid())[0], socket.gethostname())), EMAIL_RECIPIENT, 'xml-files', file)) mx = namesclient.lookupMailExchange('googlemail.com') mx.addCallback(got_mx)
def check_domain(self, domain_name): print 'check_domain:', domain_name if domain_name == self.public_dns: return defer.succeed(True) def printresult(records): answers, authority, additional = records for a in answers: print 'a', a.name, a.type, a.fmt, a.payload.name try: if str(a.payload.name) == self.public_dns: return True except: pass return False d = client.lookupMailExchange(domain_name) d.addCallback(printresult) return d
def cmd_send(self, args): "send <uuid> -- send before extracted xml files to the Coherence home base" if os.path.isdir(os.path.join('/tmp', args[0])) == 1: cwd = os.getcwd() os.chdir('/tmp') import tarfile tar = tarfile.open(os.path.join('/tmp', args[0] + '.tgz'), "w:gz") for file in os.listdir(os.path.join('/tmp', args[0])): tar.add(os.path.join(args[0], file)) tar.close() os.chdir(cwd) def got_mx(result): mx_list = result[0] mx_list.sort(lambda x, y: cmp(x.payload.preference, y.payload.preference)) if len(mx_list) > 0: import posix import pwd import socket reactor.connectTCP(str(mx_list[0].payload.name), 25, SMTPClientFactory('@'.join((pwd.getpwuid(posix.getuid())[0], socket.gethostname())), '*****@*****.**', 'xml-files', os.path.join('/tmp', args[0] + '.tgz'))) mx = namesclient.lookupMailExchange('googlemail.com') mx.addCallback(got_mx)