SendEmail - Script reading database file with sleep command

Hello,
I would like to send email message to my mail list.
I have been running linux based server and I submitted this process manually up to now.
I would like to send each individual with a shell script.

In ssh panel, I tested below command and it works smoothly.

sendEmail -t member1@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt 

I created all ssh lines for each member and put them into a ssh file, then run the script. Here it is:

sendmail.sh

#!/bin/bash
sendEmail -t member1@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member2@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member3@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member4@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
exit 0 

If I do not put "sleep" command in shell script, the server gives error.

In ssh panel:

./sendmail.sh

My excel file is in below form:

member1@hotmail.com    Name1    Surname1
member2@hotmail.com    Name2    Surname2
member3@hotmail.com    Name3    Surname3
member4@hotmail.com    Name4    Surname4
member5@hotmail.com    Name5    Surname5

Do not know which file extension should be used instead of excel file.
How can I change above script so that it reads mail-list database file and submit email to each member one by one with five seconds of interval.

Please help me.

Thanks

There are some tools that can directly read Excel files, but an easy way to process data from an Excel spreadsheet is to export that data into a CSV (comma separated values) format file. You can then easily use the shell read command (with IFS=","), awk (with FS=","), and lot of other tools to extract the data you want from the CSV file and invoke sendEmail in a loop.

1 Like