receive and parse email in bash (or execute script when message is received)
I am trying to figure out a way that when an email is received on my local machine the mail program will execute a bash script echoing the full email message into the script. I have been searching, and not found much for receiving / parsing email in bash, just how to send it. If anyone has a direction they could point me in, it would be greatly appreciated.
My intent goes something along these lines:
message recieved >> execute script (echo message) & >> delete message
The script itself will parse the message with case statements so I can create SNMP traps from the message itself. I am not too worried about the script, as I have ideas on how to do that part, but getting the darn data in there has got me stumped.