I need to send email to receipient in each block of data in a file which has the sender address under TO and just send that block of data where it ends as COMPANY.
I tried to work this out by getting line numbers of the string HELLO but unable to grab the next block of data to send the next email. i used commands like
grep -n "TO :" Sample2.txt|cut -d ":" -f 1,3| tr -d ' '
to get line numbers with email ids.
sed -n '/HELO/,/HELO/p' Sample2.txt this is where i am unable to get the corresponding block for that email id.
The sample file is
HELLO
MAIL FROM: <A@B.COM>
RCPT TO: <RCPT1@TEMP.COM>
Date: 16 JUN 11 18:28:41 EST
FROM: TEMPSENDER@EMAIL.COM
TO : TEMPRECEIVER@EMAIL.COM
DATA
ABCDCDCDCDC
THANK YOU,
COMPANY
.
HELLO
MAIL FROM: <A@B.COM>
RCPT TO: <RCPT2@TEMP.COM>
Date: 16 JUN 11 18:28:41 EST
FROM: TEMPSENDER@EMAIL.COM
TO : TEMPRECEIVER2@EMAIL.COM
DATA
ASDASDSADASDASD
THANK YOU,
COMPANY