Contribute  :  Calendar  :  Advanced Search  :  Site Statistics  :  Directory  :  Files to download  :  Links for developers  :  Privacy policy  :  Web Resources  :  Polls  
    MacOSX Guru Site Information, tips and tricks, FAQ for Mac OS X developers    
 Welcome to MacOSX Guru Site
 Thursday, November 27 2014 @ 09:16 AM UTC

Snow Leopard: Mail.app not recognizing Unix attachments as before…

   
OS X FAQIf under Leopard and before, you received email messages containing attachments the old Unix way:

begin 644 filename.ext
...uuencode stream here...
end
you may be surprized to see that Snow Leopard doesn't allow to use quick view anymore even if the attachement is of well known file extension (.html as an exemple…)

The attachment is now displayed as a "Mail Attachment" and visible only in any text editor… with TextEdit proposed as the default one.
Quite annoying if you have Unix jobs sending you automatic reports with bash lines like this:

uuencode filename.ext filename.ext | mail -s "My beautiful report" reader@mycompany.com
This doesn't work as before if "reader" is now using Snow Leopard… You have to do something like this:

#!/bin/sh

function usage
{
	echo "Usage: $0 [-h] | [-t mimetype] [-e encoding] pathtoreport from to cc [cc ...]" 1>&2
}

set -- `getopt ht:e: "$@"` || { 
	exit 1
}

# our defaults: set yours…
mimetype="text/html"
encoding="ISO-8859-1"

while :
do
	case "$1"
	in
		-t)
			mimetype=$2; shift 2;;
		-e)
			encoding=$2; shift 2;;
		-h)
			help=$1; shift;;
		--)
			shift; break;;
	esac
done

if test "$help" = "-h"
then
	usage
	exit 0
fi

if [ $# -lt 4 ]
then
	usage
	exit 1
fi

pathtoreport=$1
from=$2
to=$3
cc=$4

shift 4
ccs=$@

for cc1 in "$ccs"
do
	cc="$cc, $cc1"
done
		
subject=`basename $pathtoreport`
b=`date +%Y%m%d%H%M%s`
boundary="--MYBOUNDARY_ID-"$b
(
cat <<EOF
MIME-Version: 1.0
To: $to
Cc: $cc
Content-type: multipart/alternative; boundary=$boundary
From: $from
Subject: $subject
Reply-To: $from

$boundary
Content-Transfer-Encoding: quoted-printable
Content-Type: $mimetype;
	charset=$encoding

$(cat "$pathtoreport")

$boundary
EOF
) | /usr/sbin/sendmail -t
And call it that way:

sendreport.sh PATH_TO/filename.ext sender@thisserver.com reader@mycompany.com other@mycompany.com
Feel free to adapt to your taste and context of usage... And of course, if you know of another solution invoking only some settings to change at client side under Snow Leopard: let us know !
 

What's Related

Story Options

Snow Leopard: Mail.app not recognizing Unix attachments as before… | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
 Copyright © 2014 MacOSX Guru Site
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.06 seconds