[plug] send e-mail via command line
Craig Ringer
craig at postnewspapers.com.au
Sun Aug 10 16:24:40 WST 2003
> If you cannot find an tools that support the command-line options that
> you want, you could just craft the entire mail message like this:
>
> # (echo "To: John Miller <a at b.c>"; echo "From: Robot <d at e.f>"; echo "Subject: task completed"; echo; hostname) | sendmail -t
>
> The above is a bit of an awkward-looking command but that is because I
> am not making use of any shell tricks.
The shell tricks way (well, under bash anyway):
SENDMAIL=/usr/sbin/sendmail
ADDRESSES="user at example.com"
$SENDMAIL -t $ADDRESSES <<__END__
To: "User <user at example.com>"
Subject: the subject
From: "Notification Bot <nobody at example.com>"
body text on these lines
__END__
This can make it a bit easier to construct a message. You are quite
likely to want to append the output of some job to the end of that too.
That said, using /usr/(lib|sbin)/sendmail really is the clunky way, and
it's much more easily done using mailx (providing the 'mail' command).
Craig Ringer
More information about the plug
mailing list