Hi,
I am using following code to send an e-mail with attachment and body.
echo "To: user1@mail.com,user2@mail.com" > mail.tmp
echo "Cc: user3@mail.com,user4@mail.com" >> mail.tmp
echo "From: group@mail.com" >> mail.tmp
echo "Subject: my report" >> mail.tmp
echo "please see as attached" >> mail.tmp
uuencode /path/report.csv report.csv >> mail.tmp
cat mail.tmp | /usr/sbin/sendmail -t
But when I am executing it, its throwing me an error message saying "No recipient addresses found in header"
My OS details:
Linux 2.6.9-89.35.1.ELsmp #1 SMP Tue Jan 4 22:29:01 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
Can someone please help how I can fix this?
Thanks
Maybe it wants a space after the comma? Does it work for one address per line?
DGPickett,
Unfortunatly No...I tried with one e-mail account and its giving me the same error message.
I seem to recall the order was "Received: ", "Date: ". "From:", "Subject: ", "To: ", in email files/streams I viewed. Maybe it is fussy.
That also didnt work ...now I tried with a different script
export MAILTO="user1@mail.com"
export MAILCC="user2@mail.com"
export FROM="group@mail.com"
export SUBJECT="My report"
export BODY="/path/matter.html"
export ATTACH="/path/report.csv"
(
echo "From: $FROM"
echo "To: $MAILTO"
echo "Cc: $MAILCC"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo '---q1w2e3r4t5'
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $BODY
echo '---q1w2e3r4t5'
echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
echo "Content-Transfer-Encoding: base64"
echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
uuencode --base64 $ATTACH $(basename $ATTACH)
echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail -F $MAILTO -t $MAILCC
It works fine, but the only problem is body is missing whenever the e-mail is sent. Can you help?
Maybe it uses blank lines like http to separate header from data?
MIME - Wikipedia, the free encyclopedia
Mime Fun Fact:
Well my first code worked when I changed the mail path to /tmp/mail.tmp
anyways thanks for your help.