SHIFT

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

User Tools

Site Tools


Sidebar

Sponsor:

Would you like to sponsor this site?
Or buy me a beer?:


Recently Changed Pages:

View All Pages
View All Q Pages


View All Tags


Sign up for Q to post comments.





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.


Terms And Conditions for Q users


Pages with comments

PageDateDiscussionTags
2019/05/01 14:08 2 Comments
2019/03/15 16:02 1 Comment
2019/03/15 16:02 1 Comment
2019/03/15 16:02 3 Comments
2017/04/20 15:28 1 Comment
2017/04/20 15:23 1 Comment
2017/04/19 14:44 1 Comment
2017/04/17 20:10 1 Comment
2017/04/17 20:07 1 Comment
2017/04/17 19:58 1 Comment
2017/04/17 19:52 1 Comment

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: 2013/02/03 14:57 by sjoerd