1

I'm trying to loop over each line in a text file where each line is a URL and then send each line from the same email address, to the same email address using sendmail.

I'm running OS X and doing trying to do this with a bash script and this is what I have so far

while IFS= read -r line
do
    echo $line
    echo $line | sendmail -f [email protected] [email protected]
done < readinglistlinksfromsafari.txt

Problem is, the messages sent are all empty, even though the links echo out correctly. What do you think this could be?

I'm fairly new to this so you'll have to forgive my ignorance.

1
  • Wouldn't it make sense to send them all in a single email message, though? Commented Aug 30, 2014 at 20:40

1 Answer 1

2

Sendmail expect header and body separated by empty line.

while IFS= read -r line
do
    echo $line
/usr/sbin/sendmail -i -f [email protected] [email protected] <<END
Subject: MySubject
From: [email protected]
To: [email protected]

$line
END
done < readinglistlinksfromsafari.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.