2016-02-18 65 views

回答

0

例如,最好使用mailgun api validor。

def get_validate(): 
return requests.get(
    "https://api.mailgun.net/v3/address/validate", 
    auth=("api", "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"), 
    params={"address": "[email protected]"} 
0

例子:https://github.com/diegovalle/crimenmexico/blob/master/api/forms.py

view.py:

def get_validate(email): 
    return requests.get(
      "https://api.mailgun.net/v3/address/validate", 
      auth=("api", "pubkey-f387c7feae844803cdda9c99d4b976cb"), 
      params={'address': email}) 


rq = get_validate(email) 
if rq is not None: 
    data_email = rq.json() 
    if data_email['is_valid'] == False: 
     if data_email['did_you_mean'] is not None: 
      print("Error, Wrong Email") 
     else: 
      print("Error, Wrong Email") 
    else: 
     print("Ok, Email Correct")