Search This Blog

Tuesday, January 16, 2018

Batch send Email to each address

My loop_email.sh

Please notice each receipts only see their own Address.
The [To: ], makes the Outlook display correctly.

#!/bin/bash

while read -r line
do
    name="$line"
    echo "Name read from file - $name"
    echo "To: $name" > /tmp/email.txt
    cat ./email.txt >> /tmp/email.txt
    /usr/sbin/sendmail $name < /tmp/email.txt
    echo "...sent email to - $name"
done < ./address.csv


Email in a format example:

Subject: My Testing Email Subject
From: milliondollarserver.com

Dear Friend,

Line 1

Best Regards,


Email Address example:

test@milliondollarserver.com
lambert@milliondollarserver.com

No comments:

Post a Comment