diff --git a/tests/test_email.py b/tests/test_email.py index 79490d6ff51e232bc30a30ead3e321aa4b5bbf41..5c2b111ac480b622a6e7e251e5044397edc3f7fb 100755 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -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))