The Section Sending Files; Using mhmail and viamail had an introduction to mhmail. This section shows some examples of its uses in programming.
For instance, to mail a temporary file named $temp to the user who is running your Bourne shell script ($USER), your script could execute:
mhmail $USER -subject "XXX XXX" < $tempBe sure to use a left angle bracket (<), not a right angle bracket (>). If the standard input (here, the file $temp) is empty, mhmail won't send a message. The workaround is to test the file size before running mhmail. If the file is empty, the echo command outputs a newline -- which is enough to make mhmail happy:
if test -s "$temp" then mhmail $USER -subject "XXX XXX" < $temp else echo | mhmail $USER -subject "XXX XXX" fiOne more "gotcha": without command-line arguments, mhmail runs inc. mhmail was designed to be similar to the standard UNIX mail command. (With no addresses, mail gets your new mail.)
[Table of Contents] [Index] [Previous: A Test Mail Setup] [Next: The mhpath Command]
This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.
Suggestions are welcome: Jerry Peek <firstname.lastname@example.org>