Here is my scenario. I have a txt file. emailADD.txt. it contains email ids every line
[email protected]
[email protected]
[email protected]
And i have files in a folder
abc.pdf
def.pdf
hij.pdf
and so on
i want a script to send email to the first id with the first attachment. then another email to second id with the second attachment and so on.
both email ids and the attachments will be stored in alphabetical order. the number of email ids and attachments stored will be equal.
Please suggest.
I have this idea from jesse_b but it doesn't involve different attachments to each email id.
#!/bin/bash
file=/location/of/emailAdd.txt
while
read -r email;
do
#printf '%s\n' 'Hello, world!' | sudo mail -s 'This is the email subject' "$email"
done < "$file"