How do I configure Sendmail or procmail to return large emails to the sender?

Discussion in 'Site & Server Administration' started by seismicmike, Dec 29, 2008.

  1. #1
    We have a client who lives overseas, and because he's in a slightly backwater area, he has very expensive internet. He said it costs him $7/Mb to use the internet. That's expensive! He would like us to be able to return to sender messages that are over 1MB with a note explaining about the issue.

    I know that procmail would allow me to filter it. In fact right now, I've got a primitive filter up (I think)

    MAILDIR=$HOME/Maildir
    
    # accept small files
    :0:
    * < 1048576
    $MAILDIR
    
    # divert large files
    :0:
    * > 1048575
    $HOME/largefiles # that's a folder I created
    Code (markup):
    This way his emails are just straight up lost. We could go through them later manually, but as I understand, procmail can't really send a message back to the sender.

    I also understand that I could configure Sendmail to reject them for a certain file size
    MaxMessageSize=1048576
    Code (markup):
    - but what I need to know is is it possible to limit this by the user?

    Sorry if this seems obvious. I'm a little bit of a noob.
     
    seismicmike, Dec 29, 2008 IP
  2. seismicmike

    seismicmike Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I may have found something. I found a procmail recipe online that would return the mail to the sender based on a specific email address. I've posted it below with a replacement of the criteria - making it the file size.

    Now, I've read that this is dangerous because it can cause accidental spam propagation, but what I need to know is if I put this in the user's ~/.procmailrc instead of the global /etc/procmailrc (which calls spamassassin btw), would I be avoiding the problem, since the user-specific ("local") rc file is run after the global one, which would mean that it's running after spamassassin?

    Thanks in advance.

    Here's the script I think I would implement:

    :0:
    * > 1048575
    | ( formail -rI"From: Automated Response <no-reply@domain.com>"; \
         echo "Email file size exceeded. This user has requested not to receive" \
         echo " messages over 1Mb in size." \
       ) | $SENDMAIL -oi -t
    Code (markup):
     
    seismicmike, Dec 29, 2008 IP