G1sms/shell/sms_EMAIL.sh

59 lines
2.1 KiB
Bash
Raw Permalink Normal View History

2019-11-27 23:43:32 +01:00
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
2019-12-10 02:31:15 +01:00
# sudo apt install ssmtp mpack
# Configure in /etc/ssmtp
# Send email with file attachement: mpack -s "Logo G1Tag" /home/pi/G1sms+/G1Tag.png dest@email.ext
2019-11-27 23:43:32 +01:00
source ./shell/init.sh
source ./shell/functions.sh
log "__SUB:sms_EMAIL.sh: START ($1=phone, $2=mail)"
2019-11-27 23:43:32 +01:00
phone="$1"
mail="$2"
MAILFILE="./wallets/$phone/$phone.email" # Contains the member EMAIL (Send BILLET)
# Initialise PHONE, PIN, PUBKEY, UNIT ...
sms_INIT_ACCOUNT "$phone" "NOSMS"
if [[ $UNKNOWN == "unknown" || "$MEMBER" == "" ]]; then
sms_ERROR "$phone" "Porte-monnaie non identifié.
Envoyez N suivi de votre pseudo membre (en respectant Majuscule et minuscule)."
exit
fi
if [[ "$mail" != "" ]]; then
echo "$mail" > "$MAILFILE"
2020-01-18 20:15:48 +01:00
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt"
echo "" > "$MAILFILE"
log "__SUB:sms_EMAIL.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
2019-11-27 23:43:32 +01:00
ipfs_node_wallets_add
else
mail=$MAIL
fi
# SEND EMAIL WITH ssmtp
2020-01-06 18:37:28 +01:00
SUBJECT="[G1sms+] $MEMBER, Message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
MESSAGE="Bonjour $MEMBER\n\nVotre porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nPour commander vos G1Billets, envoyez par SMS à $MASTERPHONE :\nBILL 10/20/50/100/200/500/1000\n\n\nA bientot <3\n$ADMINPSEUDO ($ADMINPHONE)"
2020-03-12 15:06:22 +01:00
cat ./email.txt | sed s/_EMAIL/"${mail}"/g | sed s/_SUBJECT/"${SUBJECT}"/g | sed s/_MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
2020-01-18 20:15:48 +01:00
mpack -s "[G1sms+] $PHONE, $UIDNA :: Envoyer 'BILL nnn' à $MASTERPHONE pour fabriquer des G1Billets (ci-joint exemple de verso)" ./Dos_G1Billets.odt ${mail}
2020-01-06 18:37:28 +01:00
log "__SUB:sms_EMAIL.sh: Send welcome EMAIL to $mail via ssmtp"
2019-11-27 23:43:32 +01:00
log_history $PHONE "EMAIL, $mail"
mess="[G1sms+]
$MEMBER
Votre email est : $mail
2019-12-21 22:58:36 +01:00
Mettez le à jour, si cela est nécessaire..."
2019-11-27 23:43:32 +01:00
sms_SEND "$phone" "$mess"
log "END sms_EMAIL.sh"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit