test_emal.txt file contains ur name and mail details.
#!/bin/sh
while read line
do
name=`echo $line | awk '{print($1)}'`
email=`echo $line | awk '{print ($2)}'`
if [ -z "$email" ]
then
echo " Hey how are u ? email id - $name"
else
echo " Hey Mr $name how r u ? email id - $email"
fi
name=''
email=''
done < test_emal.txt
---------- Post updated at 07:47 AM ---------- Previous update was at 07:44 AM ----------
Hi ,
Here u go..
test_emal.txt file contains ur name and mail details.
#!/bin/sh
while read line
do
name=`echo $line | awk '{print($1)}'`
email=`echo $line | awk '{print ($2)}'`
if [ -z "$email" ]
then
echo " Hey how are u ? email id - $name"
else
echo " Hey Mr $name how r u ? email id - $email"
fi
name=''
email=''
done < test_emal.txt
The following code snippet is a very simple way of sending mails as plain text or attachments:
#!/bin/ksh
subjectline="--Subject of the mail--"
echo "--Body of the mail--" >> MailingList.txt
echo Sending email ....
cat MailingList.txt |mailx -s "$Subject" -r sender@gmail.com recepient@gmail.com
This will send the body as plain text in the e-mail. In case you wish to send an attachment just replace the last line with 'uuencode' command:
uuencode MailingList.txt MailingList.txt |mailx -s "$Subject" -r sender@gmail.comrecepient@gmail.com