OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Sendmail command

From: Alan Becker (beckerasoftrends.com)
Date: Fri Mar 26 2004 - 23:10:39 CST


I have several Linux hosts that I monitor and manage. One of them is
the SMTP/POP
server for our company. Occasionally I have found it convenient to
script something
that e-mails a message/warning/info to myself (this pre-dates our
conversion to
Postfix). The technique I've used is similar to the following:

#!/bin/sh
msgf="xxxx"
echo "To: beckerasoftrends.com" >$msgf
echo "From: root user on host44" >>$msgf
echo "Subject: Test message" >>$msgf
echo "" >>$msgf
echo "Test message body text" >>$msgf
echo "" >>$msgf
cat $msgf | sendmail -t

The target mail address is a valid address that exists on our Postfix
mail server.
This script approach works just fine as long as it is executed on any
host other
than our SMTP/POP host machine. On that machine, a message like the
following is displayed:
  beckerasoftrends.com... Connecting to [127.0.0.1] via relay...
  beckerasoftrends.com... Deferred: Connection refused by [127.0.0.1]

This messaging script does work on hosts where Sendmail is the installed
MTA, and on hosts where Postfix has replaced Sendmail (as long as it is not
also the destination host). The result is the same whether the user
attempting
to send the message is root or a non-root user.

I'm interested in any suggestion for how to send messages like this
from the SMTP/POP host. I'm not hung up on making this specific
technique work, although I am certainly interested to know why it
is refusing to send the message.
TIA,
A. Becker