SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

aixmailwithencryptedattachments

Script: AIX Mail With Encrypted Attachments

This is a script that can be used to send a couple of predefined files as encrypted attachments. Very useful for sending secure reports. Also note that the password needs to be sent separately to the receiver.

#!/bin/bash
########################################################################################################################
# Author : Sjoerd Hooft
# Date Initial Version: 16 feb 2011
# Comments: sjoerd_@_getshifting_com
#
# Description:
# This is a sample script to send encrypted attachments over mail
#
# Recommendations:
# The script is designed for a 120 column terminal.
# The running user must be able to do a passwordless sudo to root.
#
# Changes:
# Please comment on your changes to the script (your name and email address, line number, description):
########################################################################################################################
 
# Script Variables
BASEDIR=`dirname $0`
MAILFROM=sjoerd_getshifting_com
MAILTO=sjoerd_getshifting_com
TEMPLATEDIR=$BASEDIR\templates
 
# Function to send mail
# Args:
# 1: FROM_ADDRESS
# 2: TO_ADDRESS
# 3: Subject
# 4: Filename of contents email
# 5: Space seperated list of files to attach
mailAttach () {
  (cat ${4}; for k in ${5}; do uuencode $k ${k##*/}; done) | \
      mailx -r ${1} -s "${3}" "${2}"
}
 
# Start Script
echo "Compressing and securing files before transmission..."
echo
echo "Enter zip-file password when a password is requested, this password should be sent to email receiver ($TOMAIL) via SMS"
(cd /tmp; \
  zip -e secured-file-`date +%d%m%Y`.zip \
    file1.xls \
    file2.xls \
    file3.xls \
    file4.xls; \
    cd -)
 
echo "Sending reports to $MAILTO by mail..."
fn_sendmail ${MAILFROM} \
        ${MAILTO} \
        "Email with encrypted attachments `date +%B` -- mail 1" \
        ${TEMPLATEDIR}/mailtext.txt \
        /tmp/secured-file-`date +%d%m%Y`.zip
 
echo "Finished sending mail"
exit

Note that you need a template which will be the body of the mail, it could look something like this:

Dear Sir/Madam,

Here are the encrypted files you requested.

Kind regards,
Sjoerd Hooft
You could leave a comment if you were logged in.
aixmailwithencryptedattachments.txt · Last modified: 2021/09/24 00:24 (external edit)