Sending emails with Dropbox using mutt

Move any file into the ~/Dropbox/muttjobs/ folder and name it recipient@server.xyz{filename and the file will be emailed to the recipient.
On the ‘server’ side have this script running as a cronjob every 5 minutes.
Ps. whitespaces are not allowed in the filename and mutt must ofcourse be properly configured.

#!/bin/bash
MUTTJOBS="/home/petur/Dropbox/muttjobs/"
MUTTTMP="/tmp/"
for i in `ls $MUTTJOBS`;
do
recipient=`echo $i|cut -d{ -f1`;
data=`echo $i|cut -d{ -f2`;
mv $MUTTJOBS$i $MUTTTMP$data;
echo "sent via dropbox"|/usr/bin/mutt $recipient -s "filename: $data" -a $MUTTTMP$data;
rm $MUTTTMP$data;
done;

Leave a Reply