Exemple #1
0
def verify(mail):
    e = VerifyEmail()
    status = e.verify_email_smtp(email=str(mail),
                                 from_host='mydomain.com',
                                 from_email='*****@*****.**')

    return status[0]  # return of 250 is valid address
def query():
    flag_exist = False
    form = query_Form()
    test = sf.getdata()
    result = model.predict(test)[0]
    result2 = model2.predict(test)

    if form.validate_on_submit():
        to = form.email.data
        flag_exist = True
        test = sf.getdata()
        result = model.predict(test)[0]
        result2 = model2.predict(test) + 0.5
        final = int(result2)

        if result == True:
            out = 'It is too crowded'
        else:
            out = 'Still available'

        e = VerifyEmail()
        status = e.verify_email_smtp(email=to,
                                     from_host='mydomain.com',
                                     from_email='*****@*****.**')

        if e.was_found(status):
            temp = 'Mudd1214: %s' % (final)
            msg = MIMEText(temp + "\n\n" + out)
            msg['Subject'] = 'Room Capacity'
            msg['From'] = gmail_user
            msg['To'] = to
            smtpserver.sendmail(gmail_user, [to], msg.as_string())
            return render_template("query.html",
                                   form=form,
                                   flag_exist=flag_exist,
                                   final=final,
                                   out=out)
        else:
            return render_template("query.html",
                                   form=form,
                                   flag_exist=flag_exist,
                                   final=final,
                                   out=out)
    return render_template("query.html", form=form, flag_exist=flag_exist)
Exemple #3
0
 def setUp(self):
     """ Instantiate the class """
     self.e = VerifyEmail()
     self.log= logging.getLogger( "TestEmailVerificationFunctions" )
Exemple #4
0
class TestEmailVerificationFunctions(unittest.TestCase):

    def setUp(self):
        """ Instantiate the class """
        self.e = VerifyEmail()
        self.log= logging.getLogger( "TestEmailVerificationFunctions" )


    def test_class_based_invalid_email(self):
        """ Test the existence of an invalid email address (class based)"""

        email = '*****@*****.**'
        self.log.debug("Testing classy invalid email address (%s)" % email)

        status = self.e.verify(
                            email=email,
                            from_host='neekware.com',
                            from_email='*****@*****.**'
                        )

        self.log.debug(status)
        self.assertEquals(self.e.EMAIL_NOT_FOUND, status)

    def test_class_based_valid_email(self):
        """ Test the existence of a valid email address (class based)"""

        email = '*****@*****.**'
        self.log.debug("Testing classy valid email address (%s)" % email)
        status = self.e.verify(
                            email=email,
                            from_host='neekware.com',
                            from_email='*****@*****.**'
                        )

        self.log.debug(status)
        self.assertEquals(self.e.EMAIL_FOUND, status)

    def test_function_based_invalid_email(self):
        """ Test the existence of an invalid email address (function based)"""

        email = '*****@*****.**'
        self.log.debug("Testing invalid email address (%s)" % email)

        found = verify_email_address(
                            email=email,
                            from_host='neekware.com',
                            from_email='*****@*****.**'
                        )

        # email doesn't exists
        self.assertEquals(found, False)


    def test_function_based_valid_email(self):
        """ Test the existence of a valid email address (function based)"""

        email = '*****@*****.**'
        self.log.debug("Testing valid email address (%s)" % email)

        found = verify_email_address(
                            email=email,
                            from_host='neekware.com',
                            from_email='*****@*****.**'
                        )
        # email exists
        self.assertEquals(found, True)


    def test_mx_query_invalid_domain(self):
        """ Query mx of an invalid domain name """

        domain = 'invalid_domain_address.com'
        self.log.debug("Testing MX Query for invalid domain (%s)" % domain)
        mx = query_mx(domain)
        self.assertEquals(len(mx), 0)


    def test_mx_query_valid_domain(self):
        """ Query mx of a valid domain name """

        domain = 'cnn.com'
        self.log.debug("Testing MX Query for valid domain (%s)" % domain)

        mx = query_mx(domain)
        self.assertNotEqual(len(mx), 0)
Exemple #5
0
def get_all_verified_emails(name, domain):

    start_time = time.time()
    emails = generate_emails_from_name_and_domain(name=name, domain=domain)
    print emails
    found_using_linkedin = []
    found_using_emailahoy = []
    # found_using_validate_email = []
    for email in emails:
        print '------'
        print 'checking ', colored(email, 'blue')
        print '------'
        info_by_email = fetch_info_by_email(email)
        if 'message' in info_by_email.keys():
            message = info_by_email['message']
            if 'Throttle' in message:
                print message
            elif 'unauthorized' in message:
                print message
            else:
                print colored('not found using linkedin', 'red'), message
        else:
            found_using_linkedin.append(email)
            # print json.dumps(info_by_email, indent=4)
        e = VerifyEmail()
        status = e.verify_email_smtp(email=email,
                                     from_host='hackerrank.com',
                                     from_email='*****@*****.**')
        if e.was_found(status):
            found_using_emailahoy.append(email)
            print >> sys.stderr, colored("found using emailahoy check:",
                                         'green'), status

        elif e.not_found(status):
            print >> sys.stderr, colored("not found using emailahoy check:",
                                         'red'), status
        else:
            print >> sys.stderr, colored("unverifiable:", 'red'), status

        # is_valid = validate_email(email, verify=True)
        # if is_valid:
        # 	found_using_validate_email.append(email)
        # 	print colored('found using validate_email', 'green')
        # else:
        # 	print colored('not found using validate_email', 'red')

    print '------'
    print 'found using linkedin'
    print colored(found_using_linkedin, 'green')
    print '------'
    print 'found using emailahoy'
    print colored(found_using_emailahoy, 'green')
    print '------'
    # print 'found using validate_email'
    # print colored(found_using_validate_email, 'green')
    # print '------'
    time_taken = int(time.time() - start_time)
    minutes = time_taken / 60
    seconds = time_taken % 60
    print 'finished in ' + str(minutes) + ' minute(s) and ' + str(
        seconds) + ' second(s).'
    return {
        'using_linkedin': list(set(found_using_linkedin)),
        'using_emailahoy': list(set(found_using_emailahoy))
    }
Exemple #6
0
        print '------'
        print 'checking ', colored(email, 'blue')
        print '------'
        info_by_email = fetch_info_by_email(email)
        if 'message' in info_by_email.keys():
            message = info_by_email['message']
            if 'Throttle' in message:
                print message
            elif 'unauthorized' in message:
                print message
            else:
                print colored('not found using linkedin', 'red'), message
        else:
            found_using_linkedin.append(email)
            # print json.dumps(info_by_email, indent=4)
        e = VerifyEmail()
        status = e.verify_email_smtp(email=email,
                                     from_host='hackerrank.com',
                                     from_email='*****@*****.**')
        if e.was_found(status):
            found_using_emailahoy.append(email)
            print >> sys.stderr, colored("found using emailahoy check:",
                                         'green'), status

        elif e.not_found(status):
            print >> sys.stderr, colored("not found using emailahoy check:",
                                         'red'), status
        else:
            print >> sys.stderr, colored("unverifiable:", 'red'), status

        # is_valid = validate_email(email, verify=True)
Exemple #7
0
 def setUp(self):
     """ Instantiate the class """
     self.e = VerifyEmail()
     self.log = logging.getLogger("TestEmailVerificationFunctions")
Exemple #8
0
class TestEmailVerificationFunctions(unittest.TestCase):
    def setUp(self):
        """ Instantiate the class """
        self.e = VerifyEmail()
        self.log = logging.getLogger("TestEmailVerificationFunctions")

    def test_class_based_invalid_email(self):
        """ Test the existence of an invalid email address (class based)"""

        email = '*****@*****.**'
        self.log.debug("Testing classy invalid email address (%s)" % email)

        status = self.e.verify(email=email,
                               from_host='neekware.com',
                               from_email='*****@*****.**')

        self.log.debug(status)
        self.assertEquals(self.e.EMAIL_NOT_FOUND, status)

    def test_class_based_valid_email(self):
        """ Test the existence of a valid email address (class based)"""

        email = '*****@*****.**'
        self.log.debug("Testing classy valid email address (%s)" % email)
        status = self.e.verify(email=email,
                               from_host='neekware.com',
                               from_email='*****@*****.**')

        self.log.debug(status)
        self.assertEquals(self.e.EMAIL_FOUND, status)

    def test_function_based_invalid_email(self):
        """ Test the existence of an invalid email address (function based)"""

        email = '*****@*****.**'
        self.log.debug("Testing invalid email address (%s)" % email)

        found = verify_email_address(email=email,
                                     from_host='neekware.com',
                                     from_email='*****@*****.**')

        # email doesn't exists
        self.assertEquals(found, False)

    def test_function_based_valid_email(self):
        """ Test the existence of a valid email address (function based)"""

        email = '*****@*****.**'
        self.log.debug("Testing valid email address (%s)" % email)

        found = verify_email_address(email=email,
                                     from_host='neekware.com',
                                     from_email='*****@*****.**')
        # email exists
        self.assertEquals(found, True)

    def test_mx_query_invalid_domain(self):
        """ Query mx of an invalid domain name """

        domain = 'invalid_domain_address.com'
        self.log.debug("Testing MX Query for invalid domain (%s)" % domain)
        mx = query_mx(domain)
        self.assertEquals(len(mx), 0)

    def test_mx_query_valid_domain(self):
        """ Query mx of a valid domain name """

        domain = 'cnn.com'
        self.log.debug("Testing MX Query for valid domain (%s)" % domain)

        mx = query_mx(domain)
        self.assertNotEqual(len(mx), 0)