#!/bin/sh
#
# Send file with email from within PriMa
#
# Maybe you have to change some settings
#

# file to save mailadress in
SAVED_EMAIL=~/.prima-email

# prompt text
#PROMPT="E-Mail Adresse: "
PROMPT="E-Mail: "

#set default mailadress
if [ -f $SAVED_EMAIL ] ; then
  DEFAULT_EMAIL=$(cat $SAVED_EMAIL)
else
  DEFAULT_EMAIL=myself@localhost.foo
fi

# get new mailadress using PriMa.input 
NEW_EMAIL=$(PriMa.input "$PROMPT" "$DEFAULT_EMAIL" "PriMa Mail")

if [ $? = 1 ]; then 
  exit 1
else	
  echo $NEW_EMAIL > $SAVED_EMAIL

#
# Send file to mailadress (the simple way, no MIME, no encoding)
#
  cat $1 | mail -s $1 $NEW_EMAIL
  exit $?
fi
