Advertise on warmetal.nl!
Click for more information
about advertising here.

Did you find this website useful? Did I save you a lot of time?
Please consider donating to support this site:

 

AIX Mail With Encrypted Attachments

#!/bin/bash
########################################################################################################################
# Author : Sjoerd Hooft
# Date Initial Version: 16 feb 2011
# Comments: sjoerd_@_warmetal_nl
#
# 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_warmetal_nl
MAILTO=sjoerd_warmetal_nl
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

Discussion

Enter your comment:
 
aixmailwithencryptedattachments.txt · Last modified: 2011/02/17 13:22 by sjoerd