@@ -1024,62 +1024,59 @@ def validate_spf_policy(global_translation, local_translation, hostname, result_
1024
1024
spf_content = result
1025
1025
1026
1026
if 'spf-has-policy' in result_dict :
1027
- try :
1028
- # https://www.rfc-editor.org/rfc/rfc7208#section-9.1
1029
- spf_sections = spf_content .split (' ' )
1027
+ # https://www.rfc-editor.org/rfc/rfc7208#section-9.1
1028
+ spf_sections = spf_content .split (' ' )
1030
1029
1031
- # http://www.open-spf.org/SPF_Record_Syntax/
1032
- for section in spf_sections :
1033
- if section == '' :
1034
- result_dict ['spf-error-double-space' ] = True
1035
- continue
1030
+ # http://www.open-spf.org/SPF_Record_Syntax/
1031
+ for section in spf_sections :
1032
+ if section == '' :
1033
+ result_dict ['spf-error-double-space' ] = True
1034
+ continue
1036
1035
1037
- if section .startswith ('ip4:' ):
1038
- data = section [4 :]
1039
- if 'spf-ipv4' not in result_dict :
1040
- result_dict ['spf-ipv4' ] = []
1041
- result_dict ['spf-ipv4' ].append (data )
1042
- elif section .startswith ('ip6:' ):
1043
- data = section [4 :]
1044
- if 'spf-ipv6' not in result_dict :
1045
- result_dict ['spf-ipv6' ] = []
1046
- result_dict ['spf-ipv6' ].append (data )
1047
- elif section .startswith ('include:' ) or section .startswith ('+include:' ):
1048
- spf_domain = section [8 :]
1049
- subresult_dict = validate_spf_policy (
1050
- global_translation , local_translation , spf_domain , result_dict )
1051
- result_dict .update (subresult_dict )
1052
- elif section .startswith ('?all' ):
1053
- # What do this do and should we rate on it?
1054
- result_dict ['spf-uses-neutralfail' ] = True
1055
- elif section .startswith ('~all' ):
1056
- # add support for SoftFail
1057
- result_dict ['spf-uses-softfail' ] = True
1058
- elif section .startswith ('-all' ):
1059
- # add support for HardFail
1060
- result_dict ['spf-uses-hardfail' ] = True
1061
- elif section .startswith ('+all' ) or section .startswith ('all' ):
1062
- # basicly whitelist everything... Big fail
1063
- result_dict ['spf-uses-ignorefail' ] = True
1064
- elif section .startswith ('v=spf1' ):
1065
- c = 1
1066
- elif section .startswith ('mx' ) or section .startswith ('+mx' ):
1067
- c = 1
1068
- elif section .startswith ('a' ) or section .startswith ('+a' ):
1069
- c = 1
1070
- elif section .startswith ('ptr' ) or section .startswith ('+ptr' ):
1071
- # What do this do and should we rate on it?
1072
- result_dict ['spf-uses-ptr' ] = True
1073
- elif section .startswith ('exists:' ):
1074
- c = 1
1075
- elif section .startswith ('redirect=' ):
1076
- c = 1
1077
- elif section .startswith ('exp=' ):
1078
- c = 1
1079
- else :
1080
- result_dict ['spf-uses-none-standard' ] = True
1081
- except Exception as ex :
1082
- print ('ex C:' , ex )
1036
+ if section .startswith ('ip4:' ):
1037
+ data = section [4 :]
1038
+ if 'spf-ipv4' not in result_dict :
1039
+ result_dict ['spf-ipv4' ] = []
1040
+ result_dict ['spf-ipv4' ].append (data )
1041
+ elif section .startswith ('ip6:' ):
1042
+ data = section [4 :]
1043
+ if 'spf-ipv6' not in result_dict :
1044
+ result_dict ['spf-ipv6' ] = []
1045
+ result_dict ['spf-ipv6' ].append (data )
1046
+ elif section .startswith ('include:' ) or section .startswith ('+include:' ):
1047
+ spf_domain = section [8 :]
1048
+ subresult_dict = validate_spf_policy (
1049
+ global_translation , local_translation , spf_domain , result_dict )
1050
+ result_dict .update (subresult_dict )
1051
+ elif section .startswith ('?all' ):
1052
+ # What do this do and should we rate on it?
1053
+ result_dict ['spf-uses-neutralfail' ] = True
1054
+ elif section .startswith ('~all' ):
1055
+ # add support for SoftFail
1056
+ result_dict ['spf-uses-softfail' ] = True
1057
+ elif section .startswith ('-all' ):
1058
+ # add support for HardFail
1059
+ result_dict ['spf-uses-hardfail' ] = True
1060
+ elif section .startswith ('+all' ) or section .startswith ('all' ):
1061
+ # basicly whitelist everything... Big fail
1062
+ result_dict ['spf-uses-ignorefail' ] = True
1063
+ elif section .startswith ('v=spf1' ):
1064
+ _ = 1
1065
+ elif section .startswith ('mx' ) or section .startswith ('+mx' ):
1066
+ _ = 1
1067
+ elif section .startswith ('a' ) or section .startswith ('+a' ):
1068
+ _ = 1
1069
+ elif section .startswith ('ptr' ) or section .startswith ('+ptr' ):
1070
+ # What do this do and should we rate on it?
1071
+ result_dict ['spf-uses-ptr' ] = True
1072
+ elif section .startswith ('exists:' ):
1073
+ _ = 1
1074
+ elif section .startswith ('redirect=' ):
1075
+ _ = 1
1076
+ elif section .startswith ('exp=' ):
1077
+ _ = 1
1078
+ else :
1079
+ result_dict ['spf-uses-none-standard' ] = True
1083
1080
1084
1081
return result_dict
1085
1082
@@ -1127,10 +1124,6 @@ def validate_ip6_operation_status(global_translation, rating, local_translation,
1127
1124
# print('SMTP SUCCESS')
1128
1125
except smtplib .SMTPConnectError as smtp_error :
1129
1126
print ('SMTP ERROR: ' , smtp_error )
1130
- except Exception as error :
1131
- # If you get this error on all sites you test against,
1132
- # please verfiy that your provider is not blocking port 25.
1133
- print ('GENERAL ERROR: ' , error )
1134
1127
1135
1128
ipv6_operational_rating = Rating (global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
1136
1129
if len (ipv6_servers_operational ) > 0 and len (ipv6_servers ) == len (ipv6_servers_operational ):
@@ -1177,10 +1170,6 @@ def validate_ip4_operation_status(global_translation, rating, local_translation,
1177
1170
# print('SMTP SUCCESS')
1178
1171
except smtplib .SMTPConnectError as smtp_error :
1179
1172
print ('SMTP ERROR: ' , smtp_error )
1180
- except Exception as error :
1181
- # If you get this error on all sites you test against,
1182
- # please verfiy that your provider is not blocking port 25.
1183
- print ('GENERAL ERROR: ' , error )
1184
1173
1185
1174
ipv4_operational_rating = Rating (global_translation , REVIEW_SHOW_IMPROVEMENTS_ONLY )
1186
1175
if len (ipv4_servers_operational ) > 0 and len (ipv4_servers ) == len (ipv4_servers_operational ):
0 commit comments