Unable to send the email in formatted way


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Unable to send the email in formatted way
# 15  
Old 08-26-2014
You cannot use a filename and a redirect like that. Try:
Code:
#!/usr/bin/bash
/usr/sbin/sendmail -oi -t <<EOF
From: abc@xyz.com
To: def@xyz.com
Subject: GAP Report
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
$(/usr/xpg4/bin/awk 'BEGIN{print "<pre>"}1' ORS='<br>' ${FILE}.txt)
EOF


Last edited by Scrutinizer; 08-26-2014 at 02:58 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 16  
Old 08-26-2014
@srinishoo,
posting the code after masking

Code:
#!/usr/bin/bash

FILE=/tmp/RicGapInfo
DAY=`date  |awk '{print $1}'| tr -s '[:upper:]' '[:lower:]'`

LIST=`grep perRicGapCount /tmp/alert.$DAY | awk '{print $5}' | sort|uniq`

if [ -f $FILE ];
then
        rm -f $FILE
fi

if [ -z $LIST ];
then
        echo "No perRicGapCount on `hostname`" >> ${FILE} <= here normal mail also works fine since it is only one line
fi

for i in $LIST
do
         Command here to get missing data | grep GAP >> ${FILE}
done

MAILFROM=`hostname`
MAILTO='def@xyz.com'
/usr/xpg4/bin/awk 'BEGIN{print "<pre>"}1' ORS='<br>' ${FILE} <<EOF | /usr/sbin/sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: GAP Report perRic
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
EOF

---------- Post updated at 10:12 PM ---------- Previous update was at 09:48 PM ----------

@scrutinizer,
that worked Smilie thanks for your help

But the email received have unexpected line breaks.
like below

Code:
GAP Ric FEYEU2012300.M4 Flag2 11 Sym FEYE14223-4 msg SEQ_NO:403 db:5 diff 398 process msg
GAP Ric FEYEU2012450.M4 Flag2 3 Sym FEY420U24.5-4 msg SEQ_NO:703 db:5 d!
 iff 698 process msg
GAP Ric FEYEU2402850.M4 Flag2 15 Sym FE1420U28.5-4 msg SEQ_NO:1940 db:5 diff 1935 process msg

GAP Ric FEYEU2002300.M4 Flag2 11 Sym FEY420U23-4 msg SEQ_NO:403 db:5 diff 398 process msg
GAP Ric FEYEU2002450.M4 Flag2 3 Sym FEYE10U24.5-4 msg SEQ_NO:703 db:5 d!
 iff 698 process msg
GAP Ric FEYEU2012850.M4 Flag2 15 Sym FEY420U28.5-4 msg SEQ_NO:1940 db:5 diff 1935 process msg

---------- Post updated 08-26-14 at 06:04 PM ---------- Previous update was 08-25-14 at 10:12 PM ----------

pls help i am still getting broken characters email

Code:
GAP Ric FEYEU2012300.M4 Flag2 11 Sym FEYE14223-4 msg SEQ_NO:403 db:5 diff 398 process msg
GAP Ric FEYEU2012450.M4 Flag2 3 Sym FEY420U24.5-4 msg SEQ_NO:703 db:5 d!
 iff 698 process msg
GAP Ric FEYEU2402850.M4 Flag2 15 Sym FE1420U28.5-4 msg SEQ_NO:1940 db:5 diff 1935 process msg

GAP Ric FEYEU2002300.M4 Flag2 11 Sym FEY420U23-4 msg SEQ_NO:403 db:5 diff 398 process msg
GAP Ric FEYEU2002450.M4 Flag2 3 Sym FEYE10U24.5-4 msg SEQ_NO:703 db:5 d!
 iff 698 process msg
GAP Ric FEYEU2012850.M4 Flag2 15 Sym FEY420U28.5-4 msg SEQ_NO:1940 db:5 diff 1935 process msg

# 17  
Old 08-27-2014
how is the content in ${FILE}?
check if that too had the broken lines
# 18  
Old 08-27-2014
contents in file is not broken. it is a simple text file

Code:
GAP Ric FEYEI201402300.M4 Flag2 13 Sym FEYE1420I23-4 msg SEQ_NO:342 db:5 diff 337 process msg
GAP Ric FEYEI201402350.M4 Flag2 21 Sym FEYE1420I23.5-4 msg SEQ_NO:739 db:5 diff 734 process msg
GAP Ric FEYEI201403650.M4 Flag2 17 Sym FEYE1420I36.5-4 msg SEQ_NO:263 db:5 diff 258 process msg
GAP Ric FEYEI201402450.M4 Flag2 23 Sym FEYE1420I24.5-4 msg SEQ_NO:565 db:5 diff 560 process msg
GAP Ric FEYEI201403350.M4 Flag2 9 Sym FEYE1420I33.5-4 msg SEQ_NO:465 db:5 diff 460 process msg
GAP Ric FEYEU201402300.M4 Flag2 11 Sym FEYE1420U23-4 msg SEQ_NO:403 db:5 diff 398 process msg
GAP Ric FEYEU201402450.M4 Flag2 3 Sym FEYE1420U24.5-4 msg SEQ_NO:703 db:5 diff 698 process msg
GAP Ric FEYEU201402850.M4 Flag2 15 Sym FEYE1420U28.5-4 msg SEQ_NO:1940 db:5 diff 1935 process msg


Code:
% file /tmp/RicGapInfo.txt
/tmp/RicGapInfo.txt:    ascii text

# 19  
Old 08-27-2014
Removed the <br> part. use the below code and comment
Code:
#!/usr/bin/bash
/usr/sbin/sendmail -oi -t <<EOF
From: abc@xyz.com
To: def@xyz.com
Subject: GAP Report
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
$(/usr/xpg4/bin/awk 'BEGIN{print "<pre>"}1' ${FILE}.txt)
EOF

These 2 Users Gave Thanks to SriniShoo For This Post:
# 20  
Old 08-27-2014
@SriniShoo..and Moderators...
Thanks..
You rocked and it worked Smilie

Last edited by sdosanjh; 08-27-2014 at 05:16 AM..
# 21  
Old 08-27-2014
Then this should also work:
Code:
#!/usr/bin/bash
/usr/sbin/sendmail -oi -t <<EOF
From: abc@xyz.com
To: def@xyz.com
Subject: GAP Report
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
<pre>
$(cat "$FILE.txt")
</pre>
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Unable to send email using Java in Linux

Hi All, We recently moved to Red Hat Enterprise Linux Server release 6.6 from Solaris 10. The existing Java code to send emails in Solaris is public class card_cardMessenger{ /** * Send an e-mail message via the Runtime class * @see Runtime * @return boolean (success or failure of... (1 Reply)
Discussion started by: Meghan2525
1 Replies

2. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

3. Linux

Unable to send email with sendmail from PHP 5.3 on CentOS VM

I have a longstanding issue on my CentOS 5.6 VM where I am unable to send email from my PHP application. This is the last bunch of lines from my /var/log/maillog file. Feb 14 10:29:16 dev53 sendmail: s1EATEEo004637: Authentication-Warning: www.craig.dev-crmpicco.lan: apache set sender to... (2 Replies)
Discussion started by: crmpicco
2 Replies

4. Shell Programming and Scripting

urgent: Not able to send the html formatted message from mailx

<html> <body style=background-color:AliceBlue> <p>Hi,<pre>please check the connectivity status of the server. <pre> And find the server log file for more details. </p> <h1><font size="4">SERVER <font color="red">111.111.11.1</font> IS NOT AVAILABLE IN ONLINE</font></h1> <font color="red"... (5 Replies)
Discussion started by: jothi basu
5 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Solaris

Unable to send email to the outside world

Hi all, Iam unable to send mail from my unix machine(solaris x86,version 5.10) to the outside world. I can able to access the internet,but not able to send to any yahoo or company email id. Before posting this,i have searched this forum many times,but could not get the results what i... (5 Replies)
Discussion started by: jayaprakash
5 Replies

7. Shell Programming and Scripting

unable to send an email attachment

i know its pretty repeated query, but i need to post it in this new thread coz i need it urgently uuencode /var/tmp/chandra/emaillist.txt emaillist.txt | mail -s "message with encoded attachment" am unable to send the attachment emaillist.txt present in the path /var/tmp/chandra/ Is... (11 Replies)
Discussion started by: cmaroju
11 Replies

8. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question