try ssl-encrypted mails
This commit is contained in:
58
action.sh
58
action.sh
@@ -37,6 +37,10 @@ SYSUSER=$(whoami)
|
|||||||
NOTES="$HOME/$SYSUSER-Notes.txt"
|
NOTES="$HOME/$SYSUSER-Notes.txt"
|
||||||
NOTESTMP=.Notes.txt.tmp
|
NOTESTMP=.Notes.txt.tmp
|
||||||
|
|
||||||
|
MAILTYPE=mailsendenc # Use mailsend for plaintext, mailsendenc for SSL-encrypted details
|
||||||
|
SSLKEY=ssl.key # Only needed when using mailsendenc
|
||||||
|
MAILTMP=.mail.txt.tmp
|
||||||
|
|
||||||
## FUNCTIONS
|
## FUNCTIONS
|
||||||
function checkaction {
|
function checkaction {
|
||||||
REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$|^sizeall$|^sizeuser$|^viewdata$"
|
REGEX="^adduser$|^changepw$|^listusers$|^userdetail$|^deluser$|^sizeall$|^sizeuser$|^viewdata$"
|
||||||
@@ -80,7 +84,6 @@ function mailsend {
|
|||||||
SUBJECT="[$DOMAIN] $1";
|
SUBJECT="[$DOMAIN] $1";
|
||||||
MSGBODY1="$2"
|
MSGBODY1="$2"
|
||||||
MSGBODY2="$3"
|
MSGBODY2="$3"
|
||||||
TMP=`mktemp`
|
|
||||||
|
|
||||||
printf '%s\n' "From: $FREMAIL
|
printf '%s\n' "From: $FREMAIL
|
||||||
To: $TOEMAIL
|
To: $TOEMAIL
|
||||||
@@ -90,9 +93,56 @@ Subject: $SUBJECT
|
|||||||
$MSGBODY1
|
$MSGBODY1
|
||||||
|
|
||||||
$MSGBODY2
|
$MSGBODY2
|
||||||
" > $TMP
|
" > $MAILTMP
|
||||||
cat $TMP | "$SENDMAILPATH" -t;
|
cat $MAILTMP | "$SENDMAILPATH" -t;
|
||||||
rm $TMP;
|
rm $MAILTMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mailsendenc {
|
||||||
|
|
||||||
|
if [ ! -e $SSLKEY ]; then
|
||||||
|
#echo "Encryption key \"$SSLKEY\" is not available. Aborting."
|
||||||
|
#exit 1
|
||||||
|
|
||||||
|
openssl genrsa -out $SSLKEY 2048
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOEMAIL="$TOEMAIL";
|
||||||
|
FREMAIL="$FREMAIL";
|
||||||
|
SUBJECT="[$DOMAIN] $1";
|
||||||
|
MSGBODY1="$2"
|
||||||
|
MSGBODY2=$(echo $3 | openssl rsautl -inkey $SSLKEY -encrypt > $MAILTMP.crypt)
|
||||||
|
BOUNDARY="ZZafgwejwepfgkl.9453x1q"
|
||||||
|
ATTACHMENT=$(base64 $MAILTMP.crypt)
|
||||||
|
|
||||||
|
printf '%s\n' "From: $FREMAIL
|
||||||
|
To: $TOEMAIL
|
||||||
|
Reply-To: $FREMAIL
|
||||||
|
Subject: $SUBJECT
|
||||||
|
Mime-Version: 1.0
|
||||||
|
Content-Type: multipart/mixed; boundary=\"$BOUNDARY\"
|
||||||
|
|
||||||
|
--${BOUNDARY}
|
||||||
|
Content-Type: text/plain; charset=\"us-ascii\"
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
Content-Disposition: inline
|
||||||
|
|
||||||
|
$MSGBODY1
|
||||||
|
|
||||||
|
$MSGBODY2
|
||||||
|
|
||||||
|
--${BOUNDARY}
|
||||||
|
Content-Type: text/plain
|
||||||
|
Content-Transfer-Encoding: base64
|
||||||
|
Content-Disposition: attachment; filename=\"message.txt.crypt\"
|
||||||
|
|
||||||
|
$ATTACHMENT
|
||||||
|
|
||||||
|
--${BOUNDARY}
|
||||||
|
|
||||||
|
" > $MAILTMP
|
||||||
|
cat $MAILTMP | "$SENDMAILPATH" -t;
|
||||||
|
rm $MAILTMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
## FIRST CHECKS
|
## FIRST CHECKS
|
||||||
|
|||||||
Reference in New Issue
Block a user