Quote:
Originally Posted by Woodsman
Learning sendmail is not high on my list. (..) Seems like sendmail is significant overkill for such a nominal need.
|
I think that is debatable both in terms of performance and skills necessary to configure Sendmail to run. After all only having to fix the localhost line did it, right? :-]
Quote:
Originally Posted by Woodsman
Perhaps I'm misreading your reply
|
Yes, you did. Anyway. I'll describe my take on an alternative since I am not familiar with
nullmailers (though probably a better alternative). This example should catch e-mail, hand off to the MDA and store in a simple mailbox uses Bash and Procmail, plus Netcat or (X)inetd. The listener will only listen on localhost and deliver to a user called "mailcatch":
Procmail recipe:
Code:
# /home/mailcatch/procmail.conf
# description: Rudimentary mail catcher.
PATH=/usr/local/bin:/usr/bin:/bin
VERBOSE=on
LOGABSTRACT=all
LOGFILE=/home/mailcatch/procmail.log
DEFAULT=/home/mailcatch/mbox
:0
*
$DEFAULT
Xinetd configuration file:
Code:
# /etc/xinetd.d/smtp
# default: on
# description: Rudimentary mail catcher.
service smtp
{
disable = no
socket_type = stream
protocol = tcp
port = 25
wait = no
user = root
server = /usr/bin/procmail
server_args = -t -f - -o -Y -m /home/mailcatch/procmail.conf
log_on_failure += USERID
only_from = 127.0.0.1/32
max_load = 1
}
Netcat alternative:
Code:
#!/bin/bash
#/etc/rc.d/rc.mailcatcher or something
# description: Rudimentary mail catcher.
mailcatch() { # Restarting listener
/usr/bin/nc -n -4 -l 127.0.0.1 25 2>&1 \
|/bin/grep -v "^Conn.*accepted$" \
|/usr/bin/procmail -t -f - -o -Y -m /home/mailcatch/procmail.conf
}
case "$1" in
start) mailcatch || mailcatch;;
stop) /usr/bin/pkill -9 -f '/usr/bin/nc -n -4 -l 127.0.0.1 25' >/dev/null 2>&1;;
restart) $0 stop; $0 start;;
esac
exit 0
To test copy a single message to a temporary file and remove any delivery or post-delivery flags the MTA, MDA or MUA added. Stop any MTA from running, then 'cat -v message | nc localhost 25', then check the $LOGFILE. I only tested with nc and mailbox format messages so YMMV(VM) as usual.
HTH