summaryrefslogtreecommitdiff
path: root/test/create_mails.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/create_mails.sh')
-rwxr-xr-xtest/create_mails.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/create_mails.sh b/test/create_mails.sh
new file mode 100755
index 0000000..15da45c
--- /dev/null
+++ b/test/create_mails.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# Set this to the local user who will recieve the test emails.
+# It's recommended that this user is a simple non-login user
+# specifically for email testing.
+#
+UNAME=kbstest
+
+# Check the environment
+#
+if [ ! -x ../src/kbs ] ; then
+ echo kbs not built!
+ exit
+fi
+
+if [ "`netstat -a | egrep LISTEN | egrep smtp`" = "" ] ; then
+ echo No SMTP server
+ exit
+fi
+
+function email()
+{
+ cat << ENDMAIL > /dev/tcp/localhost/25
+HELO localhost
+MAIL FROM: $1
+RCPT TO: $UNAME
+DATA
+To: $2
+Subject: $3
+Content-Type: $4
+
+Test $5
+
+.
+QUIT
+ENDMAIL
+
+ echo Created email from $1 to $2
+}
+
+# Send the test emails
+#
+email "trusted@google.com" "uname@hostname" "" "text/plain" 1
+email "bad_user@microsoft.com" "uname@hostname" "good" "text/plain" 2
+email "trusted@google.com" "uname@hostname" "good" "text/plain" 3
+email "trusted@google.com" "uname@hostname" "bad" "text/plain" 4
+email "good_user@freebsd.org" "uname@hostname" "bad" "text/plain" 5
+email "good_user@freebsd.org" "uname@hostname" "bad" "text/html" 6
+email "good_user@google.com" "uname@hostname" "good" "text/plain" 7
+email "bad_user@google.com" "uname@hostname" "good" "text/html" 8
+email "bad_user@google.com" "uname@hostname" "bad" "text/plain" 9
+email "bad_user@google.com" "uname@hostname" "bad" "text/html" 10
+email "bad_user@google.com" "uname@hostname" "b_a_d" "text/plain" 11
+email "bad_user_uname@google.com" "baduname@hostname" "good" "text/plain" 12
+email "bad_user_hname@google.com" "uname@badhostname" "good" "text/plain" 13
+email "bad_user2@google.com" "uname@hostname" "good" "text/plain" 14