-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailSender.sh
46 lines (39 loc) · 1.06 KB
/
mailSender.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# send individual mails to multiple recepients from csv file "<emailAddress>,<firstName>"
function send () {
# change from address
toEmailAddress=$1
firstName=$2
firstName="$(echo "${firstName}" | sed -e 's/[[:space:]]*$//')" # remove trailing white space from firstName
(
echo "From: Someone <$from>";
echo "To: $toEmailAddress";
echo "Subject: The Subject of the mail";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
# email content
# change email content as desired
echo "
<html>
<head>
<title>HTML E-mail</title>
</head>
<body>
Hi $firstName,
<br>
Check out this cool stuff <a href='http://www.google.com'>here</a>.
</body>
</html>
"
) | sendmail $toEmailAddress
}
# read mail addresses and firs names from .csv file
# last row of csv is not read --> insert twice
cat listOfEmailAddresses.csv | while read line
do
emailAddress=`echo $line | cut -d ',' -f1` #get emailAddress
firstName=`echo $line | cut -d ',' -f2` #get firstName
send $emailAddress $firstName
done