[TriLUG] How can I send mail without a client ?

Jon Carnes jonc at nc.rr.com
Sat Jun 21 01:48:32 EDT 2003


I do this all the time. Since this is your first time, maybe an example
will help:
  cd /var/log
  grep -i error messages |mail -s "message log errors" me at domain.com

The results of the grep command are piped over to the mail command.
In the mail command the "-s" indicates the subject of the mail.
The mail is sent to me at domain.com, and is sent from whoever the local
user happens to be.

You can send to multiple addresses:
  echo "Hi" |mail -s "test" -c him at dom2.com me at domain.com,you at dom2.com

This tiny message goes out with the subject "test" and is sent to:
me at domain.com and you at dom2.com. The message is also cc'ed to
him at dom2.com

I do this sort of thing all the time.  Here is a standard program that I
run hourly on most servers... it's a simple volume and inode size test:
   MSG=`df -ah |grep 9[56789]%`
   if [ ! "xxx" == "xxx$MSG" ]; then
     echo $MSG |mail -s "Volume Space Low on Server: GDM1" admin at dom.com
   fi
   #
   MSG=`df -iah |grep 9[56789]%`
   if [ ! "xxx" == "xxx$MSG" ]; then
     echo $MSG |mail -s "Inode problem on Server: GDM1" admin at dom.com
   fi

Take care - Jon Carnes

On Fri, 2003-06-20 at 15:55, Sean Murphy wrote:
> On Fri, 2003-06-20 at 15:52, Ryan Leathers wrote:
> > I would like to send emails based on events in logs and so on.
> > I have no trouble selecting events in an automated way.
> > I bet I can also format text to conform to some convention.
> > 
> > This needs to be unattended - automatic - magic.
> > What is a simple way to send this email without writing code?
> > What do non-programmers use to solve this kind of thing?
> > Telnet to port 25 of some mail server?
> 
> What about the mail command? Set it up as a cron job.




More information about the TriLUG mailing list