Skip to content
Snippets Groups Projects
Commit acf5b4e0 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

spf check

Try import spf otherwise install it, and use it to validate against spf records.
parent 89ac6016
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,12 @@ import random
import time
import imp
try:
import spf
except ImportError:
status, output = subprocess.getstatusoutput('apt-get -qq -y install python3-spf')
import spf
YELLOW = '\033[93m'
GREEN = '\033[92m'
RED = '\033[91m'
......@@ -74,10 +80,10 @@ def check_relay():
print_yellow('/etc/mailname does not contain ubicast.eu or ubicast.tv, mails will probably not be received on ubicast mailing lists')
return 3
# check spf
status, output = subprocess.getstatusoutput('host -t TXT ubicast.eu')
if ip not in output:
print_red('ip %s is not in ubicast.eu SPF and emails sent from support@ubicast.eu will be treated as spam' % ip)
return 1
result, explain = spf.check2(i=ip, s='support@ubicast.eu', h='')
if result != 'pass':
print_red('ip %s is not in ubicast.eu SPF and emails sent from support@ubicast.eu may be treated as spam' % ip)
return 3
conf_relay = conf.get('EMAIL_SMTP_SERVER', '').strip('[]')
if conf_relay != configured_relay:
print_red('Configured STMP relay (%s) does not match the expected value (%s).' % (configured_relay, conf_relay))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment