- # test existence / exists
- local ret=0
- for x in "$@"; do
- [[ -e "$x" || -L "$x" ]] || ret=1
- done
- return $ret
-}
-
-# mail related
-testmail() {
- declare -gi _seq; _seq+=1
- echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
- # for testing to send from an external address, you can do for example
- # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
- # note in exim, you can retry a deferred message
- # s exim -M MSG_ID
- # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
-}
-
-# to test sieve, use below command. for fsf mail, see fsf-get-mail script.
-# make modifications, then copy to live file, use -eW to actually modify mailbox
-# cp /p/c/subdir_files/sieve/personal{test,}.sieve; testsievelist -eW INBOX
-#
-# Another option is to use sieve-test SCRIPT MAIL_FILE. note,
-# sieve-test doesn't know about envelopes, I'm not sure if sieve-filter does.
-
-# sieve with output filter. arg is mailbox, like INBOX.
-# This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
-
-testsievelist() {
- sieve-filter ~/sieve/maintest.sieve "$@" >/tmp/testsieve.log 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /tmp/testsieve.log | sort -u
-}
-
-
-# mail related
-# plain sieve
-testsieve() {
- sieve-filter ~/sieve/main.sieve "$@"
-}
-
-# mail related
-testexim() {
- # testmail above calls sendmail, which is a link to exim/postfix.
- # it's docs don't say a way of adding an argument
- # to sendmail to turn on debug output. We could make a wrapper, but
- # that is a pain. Exim debug args are documented here:
- # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
- #
- # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
- # note, for exim daemon, you can turn on debug options by
- # adding -d, etc to COMMONOPTIONS in
- # /etc/default/exim4
- # for testing external mail, you need the to address as final cmdline arg
- exim -d+tls -t <<'EOF'
-From: root@frodo.lan
-To: ian@mail.iankelling.org
-Subject: Testing Exim
-
-This is a test message.
-EOF