This script goes through a google calendar, picks up any events that contain phone numbers starting with 95, 96, 97, 99 and emails a report to $emailaddress.
My problem is that the report arrives in the email, in a single line, like this:
and I want it to arrive in the email, like this:
The problem is resolved when I change "Content-Type: text/html" to "Content-Type: text/plain", but I have to send this as html because I'm planning on adding some html code in the script.
How can I fix this?
Thanks
Bash:
#!/bin/bash
# emails $emailaddress a list of client appointments for the $currentdate
# sources $emailaddress and $currentdate from operations/variables
# sources $clientname from $clientdir/config
#variables
parentdir=$(dirname "$(dirname "$(readlink -f -- "$0")")")
source "$parentdir/operations/variables"
get_events () {
echo "Reminders Daily Report for $currentdate"
echo
for clientdir in $(ls $parentdir/clients -F | grep \/$ | sed 's#/$##') ; do
source "$parentdir/clients/$clientdir/config"
echo "$clientname Reminders $currentdate"
gcalcli --config-folder $parentdir/clients/$clientdir/auth agenda --tsv \
"$(date -d 'now')" "$(date -d 'now + 24 hours')" \
| grep -e 95 -e 96 -e 97 -e 99 \
| awk '{$1=$3=$4=""; print $0}'
echo
done
}
send_mail () {
mail -a 'Content-Type: text/html' -s "Reminders Daily Report" $emailaddress
}
"get_events" | send_mail
My problem is that the report arrives in the email, in a single line, like this:
Code:
Reminders Daily Report for 13/03/2022 Client1 Reminders 13/03/2022 21:00 991234567 21:30 991234567 Client2 Reminders 13/03/2022 21:00 991234567 21:30 991234567
and I want it to arrive in the email, like this:
Code:
Reminders Daily Report for 13/03/2022
Client1 Reminders 13/03/2022
21:00 991234567
21:30 991234567
Client2 Reminders 13/03/2022
21:00 991234567
21:30 991234567
The problem is resolved when I change "Content-Type: text/html" to "Content-Type: text/plain", but I have to send this as html because I'm planning on adding some html code in the script.
How can I fix this?
Thanks