Hi,
I try this :
#!/bin/bash
sender="me@example.com"
recipient="you@example.com"
subject="TEST FILE"
server="0.0.0.0"
file=$(cat file.txt)
/usr/bin/sendemail -f $sender -t $recipient -u $subject -m $file
My file.txt:
BLABLALA
BLABLABLA
BLABLA
But when I receive the mail inside it's like below :
BLABLALABLABLABLABLABLA
How I can keep the line feed ? Thanks by advance
(Sorry the moderators for my last post I thought having the solution but no..That's why I redo almost the same post:o)
Hello Arnaudh78,
Could you please try following and let me know if this helps you.
cat script.ksh
####Define function here to send email.
sendmail_touser() {
export MAILPART=$(uuidgen)
export MAILPART_BODY=$(uuidgen)
{
echo "From: $MAILFROM"
echo "TO: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
echo "--$MAILPART"
echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
echo ""
echo "--$MAILPART_BODY"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $Input_file_to_be_printed_in_BODY
echo "--$MAILPART_BODY--"
echo ""
echo "--$MAILPART"
} | /usr/sbin/sendmail -t
}
####Call function here to send email.
sendmail_touser
You could define values for variables into above script as per your requiremnts, please do let me know if this helps you.
Thanks,
R. Singh
1 Like
ravindersingh13:
Hello Arnaudh78,
Could you please try following and let me know if this helps you.
cat script.ksh
####Define function here to send email.
sendmail_touser() {
export MAILPART=$(uuidgen)
export MAILPART_BODY=$(uuidgen)
{
echo "From: $MAILFROM"
echo "TO: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
echo "--$MAILPART"
echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
echo ""
echo "--$MAILPART_BODY"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $Input_file_to_be_printed_in_BODY
echo "--$MAILPART_BODY--"
echo ""
echo "--$MAILPART"
} | /usr/sbin/sendmail -t
}
####Call function here to send email.
sendmail_touser
You could define values for variables into above script as per your requiremnts, please do let me know if this helps you.
Thanks,
R. Singh
Thank you for your reply, I try and I come back to you
Certainly your problem is caused by missing quotes.
All $variables should be in quotes, in case they contain special characters (like newlines).
sendemail -f "$sender" -t "$recipient" -u "$subject" -m "$file"
1 Like
madeingermany:
Certainly your problem is caused by missing quotes.
All $variables should be in quotes, in case they contain special characters (like newlines).
sendemail -f "$sender" -t "$recipient" -u "$subject" -m "$file"
Hi, Thank you it works.. decidedly I have a problem with quotes
I found the proposition of RavinderSingh interesting I'll dig in that direction too.
RudiC
September 28, 2016, 3:30pm
8
Sorry, I mixed it up with sendmail
. I wasn't aware of the perl tool sendEmail
or similar.