#!/bin/sh
### mhnftpmail - submit ftpmail request for mhn
### Usage (in mhn profile):   mhn-access-ftp: mhnftpmail
# Customize this script for your site and ftpmail server.
# 
#                             NO WARRANTY
# 
#   BECAUSE THIS PROGRAM IS AVAILABLE FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.


mhmail=/usr/local/mh/mhmail     # Absolute path to mhmail program

ftpmail='ftpmail@online.ora.com'
#ftpmail=yourname@yourhost      # Uncomment for debugging

# Build message to send in $msg (multi-line) shell variable.
# arguments passed by mhn:  $1 - domain name of ftp site, $2 - username,
# $3 - password, $4 - remote directory, $5 - remote filename,
# $6 - local filename (not used here), $7 - "ascii" or "binary":
msg="open $1 $2 $3
$7
mime
chdir $4
get $5"

# Say what's happening (on standard error):
cat << END_OF_STUFF 1>&2
`basename $0`: sending mail to '$ftpmail':

$msg

The 'Exit 1' error below makes sure mhn won't try to cache the missing response:
END_OF_STUFF

# Send mail, exit with status 1 so mhn won't think we have the content:
$mhmail "$ftpmail" -body "$msg"
exit 1
