#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2022.10.28
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "$MY_PATH/my.sh"
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################'
### PLEASE CHANGE YOUR DOMAIN AND KEY ( OR HELP PAYING TRAFIC ;)
## THIS IS A FREE LIMITED ACCOUNT. DO NOT EXAGERATE ;)
mail="$1" # EMAIL DESTINATAIRE
[[ ! $1 ]] && mail="support@qo-op.com"
messfile="$2" # FICHIER A AJOUTER AU CORPS MESSAGE
SUBJECT="[UPlanet] Astroport : $(myHostName)"
MESSAGE="Bonjour $PLAYER
UN MESSAGE POUR VOUS.
Astroport
/ipns/$IPFSNODEID
"
echo "
########################################################################
# $SUBJECT + $messfile -> $mail
########################################################################"
### SMTP RELAY
#~ echo "From: support@g1sms.fr
#~ To: EMAIL
#~ Bcc: support@qo-op.com
#~ Subject: SUBJECT
#~ $MESSAGE
#~ " > ~/.zen/tmp/email.txt
#~ [[ -s $messfile ]] && cat $messfile >> ~/.zen/tmp/email.txt \
#~ || echo "$messfile" >> ~/.zen/tmp/email.txt
#~ cat ~/.zen/tmp/email.txt | sed "s~EMAIL~${mail}~g" | sed "s~SUBJECT~${SUBJECT}~g" | /usr/sbin/ssmtp ${mail}
############# USING MAILJET API ###############
export MJ_APIKEY_PUBLIC='02b075c3f28b9797d406f0ca015ca984'
export MJ_APIKEY_PRIVATE='58256ba8ea62f68965879f53bbb29f90'
export SENDER_EMAIL='support@g1sms.fr'
export RECIPIENT_EMAIL=${mail}
echo "$MESSAGE" > ~/.zen/tmp/email.txt
[[ -s $messfile ]] && cat $messfile >> ~/.zen/tmp/email.txt \
|| echo "$messfile" >> ~/.zen/tmp/email.txt
EMAILZ=$(ipfs add -q ~/.zen/tmp/email.txt)
echo "/ipfs/${EMAILZ}"
TEXTPART=$(cat ~/.zen/tmp/email.txt | sed ':a;N;$!ba;s/\n/\\n/g' | tr '"' '\\\"')
HTMLPART=$(cat ~/.zen/tmp/email.txt | sed ':a;N;$!ba;s/\n/
/g' | tr '"' '\\\"')
export TEXTPART="${myIPFS}/ipfs/${EMAILZ}"
json_payload='{
"Messages": [
{
"From": {
"Email": "'${SENDER_EMAIL}'",
"Name": "UPlanet"
},
"To": [
{
"Email": "'${RECIPIENT_EMAIL}'",
"Name": "UPlanet Astronaut"
}
],
"Bcc": [
{
"Email": "support@g1sms.fr",
"Name": "SUPPORT"
}
],
"Subject": "'${SUBJECT}'",
"TextPart": "'${myTUBE}/ipfs/${EMAILZ}'",
"HTMLPart": "