This file was updated on Sun Oct 21 21:32:12 PDT 2007.

The email delivery plugin I wrote uses two other plugins
(smtp send and imap receive), also included, to send a message
to an email account and then check that account for the message
and delete it. The plugin times how long it takes for the
message to be delivered and the warning and critical thresholds
are for this elapsed time. 

A few notes:

1. I tried to use the check_smtp plugin for sending mail.  I
can do it on the command line but I can't get the newlines to
happen from the nagios config file (\n doesn't seem to work so smtp
server waits for the '.' but doesn't get it like it does when I
use single quote and newlines from the command line).   So if
you know how to get the check_smtp plugin to send a message from
the nagios config, that one could be used instead of the
check_smtp_send plugin included here (and please let me know)

2. The check_smtp_send plugin I included lets you specify custom
headers and body, and this is used by email delivery plugin if
you don't use the new --plugins option. If you use the new --plugins
option, then you can completely specify the check_smtp_send command
line as an option to check_email_delivery. 

3. The check_imap_receive plugin I included lets you search for
a specific message in any mailbox via options, and this is used
by email delivery plugin if you don't use the new --plugin option.
If you use the new --plugin option, then you can completely specify
the check_imap_receive command line as an option to check_email_delivery.

4. I looked at check_mail.pl by bledi51 and its pretty good,
and also conforms better to nagios perl plugin guidelnes than
mine does.  So I'm going to be revising my plugins to conform
more. 

5. There is a new option to check_email_delivery, --plugins.
You can use this option to specify complete command lines for
plugins that should be run for sending and receiving mail
(or anything else, like http file upload and ftp check to see 
that the file is there...).  So you don't have to use the
included check_smtp_send and check_imap_receive plugins, you
can use any plugins you want for checking the specific mail
services. Use the new --token option to automatically create
random numbers or strings to be passed to all specified plugins
in order to link their operation.

6. The plugin fails with UNKNOWN status code when required
perl modules are missing, and it prints a list of missing 
modules, but when I view this on my nagios website it says 
"no output!", and i've tried printing the missing modules 
list on stdout and stderr, without success.  So if anyone 
knows how to get status messages to show up when using 
UNKNOWN status code, please let me know

Finally, usage example from my own nagios config:

define command{
	command_name	check_email_delivery
	command_line	$USER1$/check_email_delivery -H $HOSTADDRESS$ --mailfrom $ARG3$ --mailto $ARG4$ --username $ARG5$ --password $ARG6$ --libexec $USER1$ -w $ARG1$ -c $ARG2$
	}

define service{
        use                             generic-service
        host_name                       mail.your.net
        service_description             EMAIL DELIVERY
        check_command                   check_email_delivery!5!120!sender@your.net!recipient@your.net!recipient@your.net!password
        }


A new usage example equivalent to the old one but using the new --plugins and --token options:

define command{
	command_name	check_email_delivery
	command_line	$USER1$/check_email_delivery -p '$USER1$/check_smtp_send -H $HOSTADDRESS$ --mailfrom $ARG3$ --mailto $ARG4$ -U $ARG5$ -P $ARG6$ --subject "Nagios %TOKEN1%" -w $ARG1$ -c $ARG2$' -p '$USER1$/check_imap_receive -H $HOSTADDRESS$ -U $ARG5$ -P $ARG6$ -s SUBJECT -s "Nagios %TOKEN1%" -w $ARG1$ -c $ARG2$' -w $ARG1$,$ARG1$ -c $ARG2$,$ARG2$
	}

define service{
        use                             generic-service
        host_name                       mail.your.net
        service_description             EMAIL DELIVERY
        check_command                   check_email_delivery!5!120!sender@your.net!recipient@your.net!recipient@your.net!password
        }


References to similar plugins:

pop3(s) email matching plugin by kkvenkit
check_mail.pl by bledi51
check_email_loop.pl by ryanwilliams
check_pop.pl and check_imap.pl by http://www.jhweiss.de/software/nagios.html

