You are previewing Procmail Companion, The.
O'Reilly logo
Procmail Companion, The

Book Description

This book will explain in easy to understand language the complexities of Procmail. With almost all linux distributions including procmail as a standard package Unix like systems and procmail are finding their way into more office and homes leaving more people wondering how to do 'the clever bits'.

The book will be split into 2 parts - the first part fairly introductory for new procmail users and the second more of a reference book for 'power procmail users'. The first part will have copious examples to help the reader using a mythical company as a running case study. The second part will provide solutions and tips and tricks for the more complex features of procmail.

Table of Contents

  1. Copyright
  2. FOREWORD
  3. PREFACE
    1. WHY DID I WRITE THIS BOOK, AND WHO IS IT FOR?
    2. ACKNOWLEDGEMENTS
  4. 1. WHAT IS PROCMAIL?
    1. WHAT IS PROCMAIL FOR?
    2. THE BASICS OF EMAIL
      1. The history
      2. The ingredients
  5. 2. SETTING UP PROCMAIL
    1. OBTAINING AND INSTALLING PROCMAIL
    2. CONTROLLING MAIL DELIVERY WITH PROCMAIL
    3. SETTING UP PROCMAIL FOR USERS
      1. Creating a .forward file
    4. RUNNING PROCMAIL MANUALLY
      1. Running Procmail manually to reprocess a mailbox
      2. Running Procmail manually to test recipes
    5. DEBUGGING PROCMAIL RECIPES
  6. 3. SIMPLE FILTERING OF EMAIL WITH PROCMAIL
    1. SETTING UP A BASIC .PROCMAILRC FILE
    2. IMPROVING EFFICIENCY
    3. IT IS NEVER THAT EASY
    4. MAKING COPIES
    5. MULTIPLE CONDITIONS IN A RECIPE
    6. DISPOSING OF EMAILS
    7. WORKING WITH EMAILS BY SIZE
    8. NESTING BLOCKS
    9. SUMMARY
  7. 4. MORE COMPLEX FILTERING USING PROCMAIL REGULAR EXPRESSIONS
    1. REGULAR EXPRESSIONS
    2. MATCHING BEGINNINGS AND ENDS
    3. MATCHING INDIVIDUAL CHARACTERS
    4. CHARACTER CLASSES
    5. SEQUENCE META-CHARACTERS
    6. WILDCARD CONFUSION
    7. WORD BOUNDARIES
    8. BUILT-IN SHORTCUTS
    9. DEFINING VARIABLES
    10. USING THE HEAD AND THE BODY
    11. OTHER RECIPE FLAGS
    12. ADDING COMPLEXITY TO CONDITIONAL LINES
      1. Matching a condition in the head or body
      2. Matching a condition against a variable
      3. OR conditionals and the else flag
    13. BACKREFERENCES – USING WHAT YOU HAVE ALREADY MATCHED
    14. SCORING
      1. The theory of scoring
      2. Limits
    15. EXTERNAL PROGRAMS
      1. Capturing output into variables
      2. Extracting data from email and filter recipes
      3. Using external programs in condition lines
      4. Where the external programs are to be found
  8. 5. USING PROCMAIL TO MANAGE MAILING LISTS
    1. ANNOUNCEMENT MAILING LIST
    2. DISCUSSION LIST
    3. DEDICATED MAILING LIST SOFTWARE
  9. 6. TROUBLESHOOTING
    1. DIAGNOSTIC MESSAGES
      1. Autoforwarding mailbox found
      2. Bad substitution of variable
      3. [pid] date time (VERBOSE)
      4. Acquiring kernel-lock (VERBOSE)
      5. Assigning “x” (VERBOSE)
      6. Assuming identity of the recipient, VERBOSE=off (VERBOSE)
      7. Bypassed locking file (VERBOSE)
      8. Can't determine your mailbox, who are you?
      9. Can't fork
      10. Can't unlock “file”
      11. Closing brace unexpected
      12. Conflicting options
      13. Conflicting “flag” suppressed
      14. Couldn't create path
      15. Couldn't create or rename temp file
      16. Couldn't determine implicit lockfile from string
      17. Couldn't make link to “path”
      18. Couldn't open “file”
      19. Couldn't rename bogus “file” into “file”
      20. Couldn't unlock “file”
      21. Deadlock attempted on “lockfile”
      22. Denying special privileges for “name”
      23. Descriptor “0/1/2” was not open
      24. Duplicate key found:
      25. Enforcing stricter permissions on “mailbox”
      26. Error while writing to “location”
      27. Exceeded LINEBUF
      28. Excessive output quenched from “source”
      29. Executing “program” (VERBOSE)
      30. Extraneous “flag” ignored
      31. Extraneous locallockfile ignored
      32. Failed forking “program”
      33. File table full
      34. Filename too long
      35. Forced unlock denied on “lockfile”
      36. Forcing lock on “x”
      37. HOST mismatched “hostname” (VERBOSE)
      38. Incomplete recipe
      39. Insufficient privileges
      40. Internal error: improper type (x) passed to foldertype for folder x
      41. Invalid field-name:
      42. Invalid regexp “regular expression”
      43. Kernel-lock failed
      44. Kernel-unlock failed
      45. Linking to “mailfile” (VERBOSE)
      46. Lock failure on “filename”
      47. Locking “filename” (VERBOSE)
      48. Lost “x”
      49. Match on “string” (VERBOSE)
      50. Matched “string” (VERBOSE)
      51. Missing action
      52. Missing argument
      53. Missing closing brace
      54. Missing name
      55. Missing rcfile
      56. Missing recipient
      57. No match on “string” (VERBOSE)
      58. No space left to finish writing “mailfile”
      59. Notified comsat: “uesr@offset:file” (VERBOSE)
      60. Opening “mailfile” (VERBOSE)
      61. Out of memory
      62. Processing continued
      63. Program failure (nnn) of “program”
      64. Quota exceeded while writing “mailfile”
      65. Rcfile: “file” (VERBOSE)
      66. Reiterating kernel-lock (VERBOSE)
      67. Renaming bogus “file” into “file”
      68. Rescue of unfiltered data succeeded/failed
      69. Score: (VERBOSE)
      70. Skipped: “string”
      71. Sorry
      72. Suspicious rcfile “file”
      73. Terminating prematurely whilst waiting for “child”
      74. Timeout, terminating “program”
      75. Timeout, was waiting for “program”
      76. Truncated file to former size
      77. Truncating “filename” and retrying lock
      78. Try praying
      79. Unexpected EOL
      80. Unknown user “name”
      81. Unlocking “lockfile” (VERBOSE)
      82. Unrecognised options:
  10. 7. INVOKING PROCMAIL
    1. PROCMAIL AS A DELIVERY AGENT
    2. PROCMAIL AS A GENERAL PURPOSE MAIL FILTER
    3. PROCMAIL AS A MAIL REPROCESSOR
    4. INVOKING FORMAIL
  11. 8. MACROS AND ENVIRONMENT VARIABLES
    1. VARIABLES
      1. COMSAT (boolean)
      2. DEFAULT (path)
      3. DELIVERED (boolean)
      4. DROPPRIVS (boolean)
      5. EXITCODE (integer)
      6. HOME (path)
      7. HOST (string)
      8. INCLUDERC (path)
      9. LASTFOLDER (path)
      10. LINEBUF (integer)
      11. LOCKEXT (string)
      12. LOCKFILE (path)
      13. LOCKSLEEP (integer)
      14. LOCKTIMEOUT (integer)
      15. LOG (string)
      16. LOGABSTRACT (string)
      17. LOGFILE (path)
      18. LOGNAME (string)
      19. MAILDIR (path)
      20. MATCH (string)
      21. MSGPREFIX (string)
      22. NORESRETRY (integer)
      23. ORGMAIL (path)
      24. PROCMAIL_OVERFLOW (boolean)
      25. PROCMAIL_VERSION (string)
      26. SENDMAIL (path)
      27. SENDMAILFLAGS (string)
      28. SHELL (path)
      29. SHELLFLAGS (string)
      30. SHELLMETAS (string)
      31. SHIFT (string)
      32. SUSPEND (integer)
      33. TIMEOUT (integer)
      34. TRAP (path)
      35. UMASK (integer)
      36. VERBOSE (boolean)
      37. ^TO_
      38. ^TO
      39. ^FROM_DAEMON
      40. ^FROM_MAILER
  12. 9. RECIPE SYNTAX
    1. VARIABLES
      1. $VARIABLE
      2. ${VARIABLE}
      3. ${VARIABLE:-default value}
      4. ${VARIABLE-default value}
      5. ${VARIABLE:+default value}
      6. ${VARIABLE+default value}
      7. $\VARIABLE
      8. $#, $1, $2, …
      9. $@
      10. $$
      11. $_
      12. $-
      13. $=
    2. COMMENTS
      1. Comments cannot occur on condition lines
      2. Comments must be outside quoted strings
      3. Comments depend on what precedes the #
    3. RECIPES
      1. Colon line
      2. Locking
      3. Conditions
        1. Condition negation
        2. Variable expansion
        3. Variable match
        4. Body match and header match
        5. Mail size
        6. Program exit code
      4. Regular expressions
      5. Actions
    4. REGULAR EXPRESSION META-CHARACTERS
    5. REGULAR EXPRESSION SHORTCUTS
    6. CONDITION TYPES
    7. COLON LINE FLAGS
  13. 10. COOKBOOK
    1. THE BASICS
      1. Basics.prc
    2. DIRECTING EMAIL TO SEPARATE MAILBOXES
      1. Problem
      2. Recipe
      3. Explanation
    3. DIRECTING A SINGLE MAIL TO MULTIPLE MAILBOXES
      1. Problem
      2. Recipe
      3. Explanation
    4. HANDLING EMAIL FROM MAILING LISTS
      1. Problem
      2. Recipe
      3. Explanation
    5. OR-ING CONDITIONS
      1. Problem
      2. Recipe
      3. Explanation
    6. RECOGNISING TEXT THAT CAN BE SPLIT ACROSS A LINE-END
      1. Problem
      2. Recipe
      3. Explanation
    7. REMOVING '[LISTNAME]' FROM SUBJECT LINES
      1. Problem
      2. Recipe
      3. Explanation
    8. SETTING THE DEFAULT DELIVERY LOCATION TO BE A FORWARDING ADDRESS
      1. Problem
      2. Recipe
      3. Explanation
  14. A. SAMPLE BUILD