mirror of
https://yerbamate.ml/nutomic/peertube.social
synced 2024-11-24 23:18:21 -05:00
28 lines
734 B
Bash
28 lines
734 B
Bash
|
#!/bin/bash
|
||
|
set -e
|
||
|
|
||
|
echo -e "This will send an email to all users, based on the template in $(pwd)/email-template.txt. Content:\n\n"
|
||
|
cat email-template.txt
|
||
|
echo -e "\n\n"
|
||
|
|
||
|
read -p "Send test email (y/N)? " SEND_EMAIL
|
||
|
case "$SEND_EMAIL" in
|
||
|
[yY]* ) ;;
|
||
|
[nN]* ) exit;;
|
||
|
* ) exit;;
|
||
|
esac
|
||
|
|
||
|
EMAIL_LIST=$(mktemp)
|
||
|
echo $EMAIL_LIST
|
||
|
docker-compose exec -T -u postgres postgres psql -U peertube -d peertube -c "SELECT email FROM public.user WHERE NOT blocked" -t > $EMAIL_LIST
|
||
|
echo "Sending email to $(wc -l $EMAIL_LIST | cut -d' ' -f1) users"
|
||
|
|
||
|
cat $EMAIL_LIST | while read EMAIL
|
||
|
do
|
||
|
echo "sending to $EMAIL"
|
||
|
cat email-template.txt | \
|
||
|
docker exec -i "$(docker-compose ps -q postfix)" sendmail -t "$EMAIL"
|
||
|
done
|
||
|
|
||
|
rm $EMAIL_LIST
|