Basic mail server test to make sure postfix is alive
authorMatthew McPherrin <matthew@mcpherrin.ca>
Tue, 13 Mar 2012 16:44:45 +0000 (12:44 -0400)
committerMatthew McPherrin <matthew@mcpherrin.ca>
Tue, 13 Mar 2012 16:44:45 +0000 (12:44 -0400)
tests.d/30_mail.py [new file with mode: 0755]

diff --git a/tests.d/30_mail.py b/tests.d/30_mail.py
new file mode 100755 (executable)
index 0000000..b64a424
--- /dev/null
@@ -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)