|
1 |
| -MailboxValidator Python Module |
2 |
| -============================== |
3 |
| - |
4 |
| -This Python module enables user to easily validate if an email address is valid, a type of disposable email or free email. |
5 |
| - |
6 |
| -This module can be useful in many types of projects, for example |
7 |
| - |
8 |
| - - to validate an user's email during sign up |
9 |
| - - to clean your mailing list prior to email sending |
10 |
| - - to perform fraud check |
11 |
| - - and so on |
12 |
| - |
13 |
| - |
14 |
| -Installation |
15 |
| -============ |
16 |
| - |
17 |
| -To install this module type the following: |
18 |
| - |
19 |
| - pip install MailboxValidator |
20 |
| - |
21 |
| - |
22 |
| -Dependencies |
23 |
| -============ |
24 |
| - |
25 |
| -An API key is required for this module to function. |
26 |
| - |
27 |
| -Go to https://www.mailboxvalidator.com/plans#api to sign up for FREE API plan and you'll be given an API key. |
28 |
| - |
29 |
| - |
30 |
| -Functions |
31 |
| -========= |
32 |
| - |
33 |
| -## SingleValidation(api_key) |
34 |
| - |
35 |
| -Creates a new instance of the MailboxValidator object with the API key. |
36 |
| - |
37 |
| -## ValidateEmail(email_address) |
38 |
| - |
39 |
| -Performs email validation on the supplied email address. |
40 |
| - |
41 |
| -### Return Fields |
42 |
| - |
43 |
| -| Field Name | Description | |
44 |
| -|-----------|------------| |
45 |
| -| email_address | The input email address. | |
46 |
| -| domain | The domain of the email address. | |
47 |
| -| is_free | Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False | |
48 |
| -| is_syntax | Whether the email address is syntactically correct. Return values: True, False | |
49 |
| -| is_domain | Whether the email address has a valid MX record in its DNS entries. Return values: True, False, - (- means not applicable) | |
50 |
| -| is_smtp | Whether the mail servers specified in the MX records are responding to connections. Return values: True, False, - (- means not applicable) | |
51 |
| -| is_verified | Whether the mail server confirms that the email address actually exist. Return values: True, False, - (- means not applicable) | |
52 |
| -| is_server_down | Whether the mail server is currently down or unresponsive. Return values: True, False, - (- means not applicable) | |
53 |
| -| is_greylisted | Whether the mail server employs greylisting where an email has to be sent a second time at a later time. Return values: True, False, - (- means not applicable) | |
54 |
| -| is_disposable | Whether the email address is a temporary one from a disposable email provider. Return values: True, False, - (- means not applicable) | |
55 |
| -| is_suppressed | Whether the email address is in our blacklist. Return values: True, False, - (- means not applicable) | |
56 |
| -| is_role | Whether the email address is a role-based email address like admin@example.net or webmaster@example.net. Return values: True, False, - (- means not applicable) | |
57 |
| -| is_high_risk | Whether the email address contains high risk keywords. Return values: True, False, - (- means not applicable) | |
58 |
| -| is_catchall | Whether the email address is a catch-all address. Return values: True, False, Unknown, - (- means not applicable) | |
59 |
| -| mailboxvalidator_score | Email address reputation score. Score > 0.70 means good; score > 0.40 means fair; score <= 0.40 means poor. | |
60 |
| -| time_taken | The time taken to get the results in seconds. | |
61 |
| -| status | Whether our system think the email address is valid based on all the previous fields. Return values: True, False | |
62 |
| -| credits_available | The number of credits left to perform validations. | |
63 |
| -| error_code | The error code if there is any error. See error table in the below section. | |
64 |
| -| error_message | The error message if there is any error. See error table in the below section. | |
65 |
| - |
66 |
| -## DisposableEmail(email_address) |
67 |
| - |
68 |
| -Check if the supplied email address is from a disposable email provider. |
69 |
| - |
70 |
| -### Return Fields |
71 |
| - |
72 |
| -| Field Name | Description | |
73 |
| -|-----------|------------| |
74 |
| -| email_address | The input email address. | |
75 |
| -| is_disposable | Whether the email address is a temporary one from a disposable email provider. Return values: True, False | |
76 |
| -| credits_available | The number of credits left to perform validations. | |
77 |
| -| error_code | The error code if there is any error. See error table in the below section. | |
78 |
| -| error_message | The error message if there is any error. See error table in the below section. | |
79 |
| - |
80 |
| -## FreeEmail(email_address) |
81 |
| - |
82 |
| -Check if the supplied email address is from a free email provider. |
83 |
| - |
84 |
| -### Return Fields |
85 |
| - |
86 |
| -| Field Name | Description | |
87 |
| -|-----------|------------| |
88 |
| -| email_address | The input email address. | |
89 |
| -| is_free | Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False | |
90 |
| -| credits_available | The number of credits left to perform validations. | |
91 |
| -| error_code | The error code if there is any error. See error table in the below section. | |
92 |
| -| error_message | The error message if there is any error. See error table below. | |
93 |
| - |
94 |
| - |
95 |
| -Sample Codes |
96 |
| -============ |
97 |
| - |
98 |
| -## Validate email |
99 |
| - |
100 |
| -```python |
101 |
| -import MailboxValidator |
102 |
| - |
103 |
| - mbv = MailboxValidator.SingleValidation('PASTE_API_KEY_HERE') |
104 |
| - results = mbv.ValidateEmail('example@example.com') |
105 |
| - |
106 |
| - if results is None: |
107 |
| - print("Error connecting to API.\n") |
108 |
| - elif results['error_code'] == '': |
109 |
| - print('email_address = ' + results['email_address'] + "\n") |
110 |
| - print('domain = ' + results['domain'] + "\n") |
111 |
| - print('is_free = ' + results['is_free'] + "\n") |
112 |
| - print('is_syntax = ' + results['is_syntax'] + "\n") |
113 |
| - print('is_domain = ' + results['is_domain'] + "\n") |
114 |
| - print('is_smtp = ' + results['is_smtp'] + "\n") |
115 |
| - print('is_verified = ' + results['is_verified'] + "\n") |
116 |
| - print('is_server_down = ' + results['is_server_down'] + "\n") |
117 |
| - print('is_greylisted = ' + results['is_greylisted'] + "\n") |
118 |
| - print('is_disposable = ' + results['is_disposable'] + "\n") |
119 |
| - print('is_suppressed = ' + results['is_suppressed'] + "\n") |
120 |
| - print('is_role = ' + results['is_role'] + "\n") |
121 |
| - print('is_high_risk = ' + results['is_high_risk'] + "\n") |
122 |
| - print('is_catchall = ' + results['is_catchall'] + "\n") |
123 |
| - print('mailboxvalidator_score = ' + str(results['mailboxvalidator_score']) + "\n") |
124 |
| - print('time_taken = ' + str(results['time_taken']) + "\n") |
125 |
| - print('status = ' + results['status'] + "\n") |
126 |
| - print('credits_available = ' + str(results['credits_available']) + "\n") |
127 |
| - else: |
128 |
| - print('error_code = ' + results['error_code'] + "\n") |
129 |
| - print('error_message = ' + results['error_message'] + "\n") |
130 |
| -``` |
131 |
| - |
132 |
| - |
133 |
| -## Check if an email is from a disposable email provider |
134 |
| - |
135 |
| -```python |
136 |
| -import MailboxValidator |
137 |
| - |
138 |
| - mbv = MailboxValidator.SingleValidation('PASTE_API_KEY_HERE') |
139 |
| - results = mbv.DisposableEmail('example@example.com') |
140 |
| - |
141 |
| - if results is None: |
142 |
| - print("Error connecting to API.\n") |
143 |
| - elif results['error_code'] == '': |
144 |
| - print('email_address = ' + results['email_address'] + "\n") |
145 |
| - print('is_disposable = ' + results['is_disposable'] + "\n") |
146 |
| - print('credits_available = ' + str(results['credits_available']) + "\n") |
147 |
| - else: |
148 |
| - print('error_code = ' + results['error_code'] + "\n") |
149 |
| - print('error_message = ' + results['error_message'] + "\n") |
150 |
| -``` |
151 |
| - |
152 |
| -## Check if an email is from a free email provider |
153 |
| - |
154 |
| -```python |
155 |
| -import MailboxValidator |
156 |
| - |
157 |
| - mbv = MailboxValidator.SingleValidation('PASTE_API_KEY_HERE') |
158 |
| - results = mbv.FreeEmail('example@example.com') |
159 |
| - |
160 |
| - if results is None: |
161 |
| - print("Error connecting to API.\n") |
162 |
| - elif results['error_code'] == '': |
163 |
| - print('email_address = ' + results['email_address'] + "\n") |
164 |
| - print('is_free = ' + results['is_free'] + "\n") |
165 |
| - print('credits_available = ' + str(results['credits_available']) + "\n") |
166 |
| - else: |
167 |
| - print('error_code = ' + results['error_code'] + "\n") |
168 |
| - print('error_message = ' + results['error_message'] + "\n") |
169 |
| -``` |
170 |
| - |
171 |
| -Errors |
172 |
| -====== |
173 |
| - |
174 |
| -| error_code | error_message | |
175 |
| -| ---------- | ------------- | |
176 |
| -| 100 | Missing parameter. | |
177 |
| -| 101 | API key not found. | |
178 |
| -| 102 | API key disabled. | |
179 |
| -| 103 | API key expired. | |
180 |
| -| 104 | Insufficient credits. | |
181 |
| -| 105 | Unknown error. | |
182 |
| - |
183 |
| -Copyright |
184 |
| -========= |
185 |
| - |
186 |
| -Copyright (C) 2018-2020 by MailboxValidator.com, support@mailboxvalidator.com |
| 1 | +MailboxValidator Python Module |
| 2 | +============================== |
| 3 | + |
| 4 | +This Python module enables user to easily validate if an email address is valid, a type of disposable email or free email. |
| 5 | + |
| 6 | +This module can be useful in many types of projects, for example |
| 7 | + |
| 8 | + - to validate an user's email during sign up |
| 9 | + - to clean your mailing list prior to email sending |
| 10 | + - to perform fraud check |
| 11 | + - and so on |
| 12 | + |
| 13 | + |
| 14 | +Installation |
| 15 | +============ |
| 16 | + |
| 17 | +To install this module type the following: |
| 18 | + |
| 19 | + pip install MailboxValidator |
| 20 | + |
| 21 | + |
| 22 | +Dependencies |
| 23 | +============ |
| 24 | + |
| 25 | +An API key is required for this module to function. |
| 26 | + |
| 27 | +Go to https://www.mailboxvalidator.com/plans#api to sign up for FREE API plan and you'll be given an API key. |
| 28 | + |
| 29 | + |
| 30 | +Functions |
| 31 | +========= |
| 32 | + |
| 33 | +## EmailValidation(api_key) |
| 34 | + |
| 35 | +Creates a new instance of the MailboxValidator object with the API key. |
| 36 | + |
| 37 | +## validate_email(email_address) |
| 38 | + |
| 39 | +Performs email validation on the supplied email address. |
| 40 | + |
| 41 | +### Return Fields |
| 42 | + |
| 43 | +| Field Name | Description | |
| 44 | +|-----------|------------| |
| 45 | +| email_address | The input email address. | |
| 46 | +| domain | The domain of the email address. | |
| 47 | +| is_free | Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False | |
| 48 | +| is_syntax | Whether the email address is syntactically correct. Return values: True, False | |
| 49 | +| is_domain | Whether the email address has a valid MX record in its DNS entries. Return values: True, False, - (- means not applicable) | |
| 50 | +| is_smtp | Whether the mail servers specified in the MX records are responding to connections. Return values: True, False, - (- means not applicable) | |
| 51 | +| is_verified | Whether the mail server confirms that the email address actually exist. Return values: True, False, - (- means not applicable) | |
| 52 | +| is_server_down | Whether the mail server is currently down or unresponsive. Return values: True, False, - (- means not applicable) | |
| 53 | +| is_greylisted | Whether the mail server employs greylisting where an email has to be sent a second time at a later time. Return values: True, False, - (- means not applicable) | |
| 54 | +| is_disposable | Whether the email address is a temporary one from a disposable email provider. Return values: True, False, - (- means not applicable) | |
| 55 | +| is_suppressed | Whether the email address is in our blacklist. Return values: True, False, - (- means not applicable) | |
| 56 | +| is_role | Whether the email address is a role-based email address like admin@example.net or webmaster@example.net. Return values: True, False, - (- means not applicable) | |
| 57 | +| is_high_risk | Whether the email address contains high risk keywords. Return values: True, False, - (- means not applicable) | |
| 58 | +| is_catchall | Whether the email address is a catch-all address. Return values: True, False, Unknown, - (- means not applicable) | |
| 59 | +| mailboxvalidator_score | Email address reputation score. Score > 0.70 means good; score > 0.40 means fair; score <= 0.40 means poor. | |
| 60 | +| time_taken | The time taken to get the results in seconds. | |
| 61 | +| status | Whether our system think the email address is valid based on all the previous fields. Return values: True, False | |
| 62 | +| credits_available | The number of credits left to perform validations. | |
| 63 | +| error_code | The error code if there is any error. See error table in the below section. | |
| 64 | +| error_message | The error message if there is any error. See error table in the below section. | |
| 65 | + |
| 66 | +## is_disposable_email(email_address) |
| 67 | + |
| 68 | +Check if the supplied email address is from a disposable email provider. |
| 69 | + |
| 70 | +### Return Fields |
| 71 | + |
| 72 | +| Field Name | Description | |
| 73 | +|-----------|------------| |
| 74 | +| email_address | The input email address. | |
| 75 | +| is_disposable | Whether the email address is a temporary one from a disposable email provider. Return values: True, False | |
| 76 | +| credits_available | The number of credits left to perform validations. | |
| 77 | +| error_code | The error code if there is any error. See error table in the below section. | |
| 78 | +| error_message | The error message if there is any error. See error table in the below section. | |
| 79 | + |
| 80 | +## is_free_email(email_address) |
| 81 | + |
| 82 | +Check if the supplied email address is from a free email provider. |
| 83 | + |
| 84 | +### Return Fields |
| 85 | + |
| 86 | +| Field Name | Description | |
| 87 | +|-----------|------------| |
| 88 | +| email_address | The input email address. | |
| 89 | +| is_free | Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False | |
| 90 | +| credits_available | The number of credits left to perform validations. | |
| 91 | +| error_code | The error code if there is any error. See error table in the below section. | |
| 92 | +| error_message | The error message if there is any error. See error table below. | |
| 93 | + |
| 94 | + |
| 95 | +Sample Codes |
| 96 | +============ |
| 97 | + |
| 98 | +## Validate email |
| 99 | + |
| 100 | +```python |
| 101 | +import MailboxValidator |
| 102 | + |
| 103 | + mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE') |
| 104 | + results = mbv.validate_email('example@example.com') |
| 105 | + |
| 106 | + if results is None: |
| 107 | + print("Error connecting to API.\n") |
| 108 | + elif results['error_code'] == '': |
| 109 | + print('email_address = ' + results['email_address'] + "\n") |
| 110 | + print('domain = ' + results['domain'] + "\n") |
| 111 | + print('is_free = ' + results['is_free'] + "\n") |
| 112 | + print('is_syntax = ' + results['is_syntax'] + "\n") |
| 113 | + print('is_domain = ' + results['is_domain'] + "\n") |
| 114 | + print('is_smtp = ' + results['is_smtp'] + "\n") |
| 115 | + print('is_verified = ' + results['is_verified'] + "\n") |
| 116 | + print('is_server_down = ' + results['is_server_down'] + "\n") |
| 117 | + print('is_greylisted = ' + results['is_greylisted'] + "\n") |
| 118 | + print('is_disposable = ' + results['is_disposable'] + "\n") |
| 119 | + print('is_suppressed = ' + results['is_suppressed'] + "\n") |
| 120 | + print('is_role = ' + results['is_role'] + "\n") |
| 121 | + print('is_high_risk = ' + results['is_high_risk'] + "\n") |
| 122 | + print('is_catchall = ' + results['is_catchall'] + "\n") |
| 123 | + print('mailboxvalidator_score = ' + str(results['mailboxvalidator_score']) + "\n") |
| 124 | + print('time_taken = ' + str(results['time_taken']) + "\n") |
| 125 | + print('status = ' + results['status'] + "\n") |
| 126 | + print('credits_available = ' + str(results['credits_available']) + "\n") |
| 127 | + else: |
| 128 | + print('error_code = ' + results['error_code'] + "\n") |
| 129 | + print('error_message = ' + results['error_message'] + "\n") |
| 130 | +``` |
| 131 | + |
| 132 | + |
| 133 | +## Check if an email is from a disposable email provider |
| 134 | + |
| 135 | +```python |
| 136 | +import MailboxValidator |
| 137 | + |
| 138 | + mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE') |
| 139 | + results = mbv.is_disposable_email('example@example.com') |
| 140 | + |
| 141 | + if results is None: |
| 142 | + print("Error connecting to API.\n") |
| 143 | + elif results['error_code'] == '': |
| 144 | + print('email_address = ' + results['email_address'] + "\n") |
| 145 | + print('is_disposable = ' + results['is_disposable'] + "\n") |
| 146 | + print('credits_available = ' + str(results['credits_available']) + "\n") |
| 147 | + else: |
| 148 | + print('error_code = ' + results['error_code'] + "\n") |
| 149 | + print('error_message = ' + results['error_message'] + "\n") |
| 150 | +``` |
| 151 | + |
| 152 | +## Check if an email is from a free email provider |
| 153 | + |
| 154 | +```python |
| 155 | +import MailboxValidator |
| 156 | + |
| 157 | + mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE') |
| 158 | + results = mbv.is_free_email('example@example.com') |
| 159 | + |
| 160 | + if results is None: |
| 161 | + print("Error connecting to API.\n") |
| 162 | + elif results['error_code'] == '': |
| 163 | + print('email_address = ' + results['email_address'] + "\n") |
| 164 | + print('is_free = ' + results['is_free'] + "\n") |
| 165 | + print('credits_available = ' + str(results['credits_available']) + "\n") |
| 166 | + else: |
| 167 | + print('error_code = ' + results['error_code'] + "\n") |
| 168 | + print('error_message = ' + results['error_message'] + "\n") |
| 169 | +``` |
| 170 | + |
| 171 | +Errors |
| 172 | +====== |
| 173 | + |
| 174 | +| error_code | error_message | |
| 175 | +| ---------- | ------------- | |
| 176 | +| 100 | Missing parameter. | |
| 177 | +| 101 | API key not found. | |
| 178 | +| 102 | API key disabled. | |
| 179 | +| 103 | API key expired. | |
| 180 | +| 104 | Insufficient credits. | |
| 181 | +| 105 | Unknown error. | |
| 182 | + |
| 183 | +Copyright |
| 184 | +========= |
| 185 | + |
| 186 | +Copyright (C) 2018-2021 by MailboxValidator.com, support@mailboxvalidator.com |
0 commit comments