Skip to content

Commit

Permalink
More secure temp folder selection in fakesendmail
Browse files Browse the repository at this point in the history
Use .eml extension for created files, works better with Apple Mail
  • Loading branch information
Synchro committed May 10, 2013
1 parent 9794677 commit bfe6f6b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/fakesendmail.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/bash
#!/usr/bin/env bash
#Fake sendmail script, adapted from:
#https://github.com/mrded/MNPP/blob/ee64fb2a88efc70ba523b78e9ce61f9f1ed3b4a9/init/fake-sendmail.sh
numPath="/tmp/fakemail"

#Create a temp folder to put messages in
numPath="${TMPDIR-/tmp/}fakemail"
umask 037
mkdir -p $numPath

if [ ! -f $numPath/num ]; then
echo "0" > $numPath/num
echo "0" > $numPath/num
fi
num=`cat $numPath/num`
num=$(($num + 1))
echo $num > $numPath/num

name="$numPath/letter_$num.txt"
name="$numPath/message_$num.eml"
while read line
do
echo $line >> $name
echo $line >> $name
done
chmod 777 $name
/bin/true
exit 0

0 comments on commit bfe6f6b

Please sign in to comment.