I have an email account that I forward to a gmail account so that I can use google’s spam filtering. One thing that google does is limit the size of mail messages to 25mb. If someone sends me a mail message with an attachment greater than 25mb, google will bounce it back to my server, which will then forward it to google, who will then bounce it back to me… you get the picture. I had this happen today and while nothing crashed, it did slow my server to a crawl. So I thought that I’d put a rule in my .procmailrc file before the forward to the gmail account that moves the large file to a local mailbox. This is easy to do, I’d just add a section like this:

:0
 * > 25000000
 bigfiles
 

This will put any mail message greater than 25mb into the bigfiles folder. The problem though is I also want to send a message to me, telling me to look in my bigfiles folder to find out what this is. That’s a little more complicated, but basically, you just put the rules in order. This works for me:

:0
 * > 25000000
 {
    :0
    *
    | mail -s "You've received a mail message larger than 25mb" me < /var/adm/bigfiles
  
    :0
    *
    bigfiles
 }

The first condition (outside the brackets) tells me to look for messages greater than 25mb. If I find one, then first I send myself (me@localhost) a message that says I’ve received a big message. The /var/adm/bigfiles file just has text saying that google won’t accept this large file and that I should check my bigfiles folder. Then the next section just moves the message to the bigfiles folder.