Skip to content
Snippets Groups Projects
test_postfix.py 547 B
Newer Older
Stéphane Diemer's avatar
Stéphane Diemer committed
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Check that emails can be sent.
Stéphane Diemer's avatar
Stéphane Diemer committed
'''
import os
import subprocess
import sys


if not os.path.exists('/etc/postfix'):
    print('Postfix dir does not exists, please install postfix.')
    sys.exit(1)
Stéphane Diemer's avatar
Stéphane Diemer committed
else:
    # check that postfix listens the port 25 correctly
Florent Thiery's avatar
Florent Thiery committed
    status, out = subprocess.getstatusoutput('netstat -pant | grep master | grep 127.0.0.1:25')
    if status != 0:
Stéphane Diemer's avatar
Stéphane Diemer committed
        print('The port 25 is not listened by any process.')
        sys.exit(1)
    print('Postfix listening port: OK.')