G1sms/shell/sms_EMAIL.sh

55 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# 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
source ./shell/init.sh
source ./shell/functions.sh
log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
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"
log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
ipfs_node_wallets_add
else
mail=$MAIL
fi
# SEND EMAIL WITH ssmtp
SUBJECT="[G1sms+] $MEMBER, message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
MESSAGE="Bonjour $MEMBER\n\nLe detenteur du porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nVous y recevrez nos prochains envois ...\n\n\nA bientot <3\n$ADMINPSEUDO - ($MASTERPHONE) Partenaire G1sms+"
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp"
log_history $PHONE "EMAIL, $mail"
mess="[G1sms+]
$MEMBER
Votre email est : $mail
Mettez le à jour, quand cela est nécessaire..."
sms_SEND "$phone" "$mess"
log "END sms_EMAIL.sh"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit