Supportnet / Forum / Linux
sendmail
Frage
hallo,
wie kann ich auf der kommandozeile via sendmail eine mail an einen user x mit dem dateianhang y schicken.
für das senden von texten habe ich das script hinbekommen. mit dem anhang klappte es bisher nicht.
vielen dank
peter
Antwort 1 von sst
schau mal hier rein...
mfg
sst
#!/bin/bash
#
# Script: sendfile
#
# Purpose: Send the specified file via email as a MIME
# attachment to the specified address.
#
# Author: Anthony E. Greene <agreene@pobox.com>
#
# License: GPL <http://www.gnu.org/>
#
# Note: This script does not include any error checking, so
# it should only be called from within other scripts.
# The correct syntax for using this script is:
#
# sendfile filename user@domain | /path/to/sendmail -t
#
# First we set up some global variables.
# Some code should be added to verify the commandline arguments.
sender=root@localhost
filename=$1
basefile=`/bin/basename $filename`
recipient=$2
DATE=`date -I`
echo From: $sender
echo To: $recipient
echo Subject: File $basefile from $DATE
echo MIME-Version: 1.0
echo "Content-Type: multipart/mixed;
Boundary=\"sendfile-attachment-boundary\""
echo
echo --sendfile-attachment-boundary
echo 'Content-Type: text/plain; charset=us-ascii'
echo
echo This is a MIME encoded message. If your mail software
echo cannot properly handle the attached file, you may need
echo to get a MIME-aware mailer.
echo
echo --sendfile-attachment-boundary
echo "Content-Type: application/octet-stream; name=\"$basefile\""
echo Content-Transfer-Encoding: base64
echo "Content-Disposition: attachment; filename=\"$basefile\""
echo
/usr/bin/mimencode $filename
echo --sendfile-attachment-boundary--
#end of script
mfg
sst
Antwort 2 von Ploepp01
im uebrigen hilft rtfm *anmerk*

