Here is what I was thinking of:
I want to create a Raspberry Pi Picture-frame (DPF) for my grandma, but with basic email support. Emails can be sent by six family members and will be received daily by fetchmail/procmail. This already works!
/home/pi/Mail/ I now have three files (one for each email including attachments):
What I want to do now is extract SENDER, SUBJECT(, TEXT) and ATTACHMENT from each file, to rename the attachment-image and add the text with imagemagick (not yet included).
for file in msg.*; do export SENDER=`tee $file | formail -zxFrom: -zxReply-To:|cut -fs- -d'<'|cut -f1 -d'>'` SUBJECT = `/bin/cat $file | formail -zxSubject:` if grep -qxis $SENDER /home/pi/Mail/.markus; then SENDER2=Markus fi if grep -qxis $SENDER /home/pi/Mail/.someone; then SENDER2=Someone fi /bin/mkdir -p /home/pi/Mail/$SENDER2 >/dev/null munpack -C /home/pi/Mail/$SENDER2 $file /bin/cat $file /bin/rm $file done
munpack part works fine, but the extraction of SENDER and SUBJECT does not work when I run the sh-file. It just looks like it froze. I can only cancel it with ctrl-c!
I don't know why, when I include line 2 and 3 in my
.procmailrc it does work without problems.
I mean that this is a somehow basic task and no wizardry, but I couldn't find anything helpful with google
Any help is appreciated! Maybe you have got another solution. I'm totally not an expert in Linux, so maybe keep it a bit simple