In a dedicated function, use re.match() to check the validity of a given email address. The function can then be called to test the validity of the FROM parameter, as well as for every addresses extracted from the parameter file. It should use a variant of the following regex (from: https://www.scottbrady91.com/Email-Verification/Python-Email-Verification-Script):
import re
addressToVerify ='info@emailhippo.com'
match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', addressToVerify)
if match == None:
print('Bad Syntax')
raise ValueError('Bad Syntax')
In a dedicated function, use re.match() to check the validity of a given email address. The function can then be called to test the validity of the FROM parameter, as well as for every addresses extracted from the parameter file. It should use a variant of the following regex (from: https://www.scottbrady91.com/Email-Verification/Python-Email-Verification-Script):