Basic mail server test to make sure postfix is alive

This commit is contained in:
Matthew McPherrin 2012-03-13 12:44:45 -04:00
parent b8301408c9
commit 0f64a1c94a
1 changed files with 22 additions and 0 deletions

22
tests.d/30_mail.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
import socket, sys
s = socket.socket()
try:
s.connect(('mail.csclub.uwaterloo.ca', 25))
l220 = s.recv(128)
except socket.error, e:
print "FAIL", e
sys.exit(1)
if not (l220.startswith("220 ") and "csclub.uwaterloo.ca" in l220):
print "FAIL: Unexpected mail server start", l220
sys.exit(1)
s.send("EHLO localhost\n")
caps = s.recv(1024).split('\n')
if len([x for x in caps if not (x.startswith('250') or len(x) == 0)]) != 0:
print "FAIL: Unexpected reply to EHLO"
sys.exit(2)
sys.exit(0)