Using Procmail - PowerPoint PPT Presentation

About This Presentation
Title:

Using Procmail

Description:

Forwarding Recipes. Multiple forwarding addresses accepted. Multiple patterns accepted ... Test your recipes before using them. Resources for more information ... – PowerPoint PPT presentation

Number of Views:111
Avg rating:3.0/5.0
Slides: 26
Provided by: eec89
Category:

less

Transcript and Presenter's Notes

Title: Using Procmail


1
Using Procmail
  • Charles Duan
  • Harvard Univ. Computer Services
  • March 27, 2002

2
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

3
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

4
What is Procmail?
  • Procmail is a processor of e-mail
  • Filter mail by headers/content
  • Multiple delivery possibilities
  • Mailboxes
  • Forwarding Addresses
  • Programs

5
Procmail Recipes
  • Procmail filters e-mails based on recipes in the
    .procmailrc file
  • Recipes contain
  • What kind of e-mail the recipe handles
  • What to do with the e-mail
  • At most one recipe executes (unless otherwise
    specified)

6
Procmailrc Syntax
A basic .procmailrc
0 Header
From ksdavis_at_fas Patterns
Important-folder Action

0 Header
Subject \UA\ Patterns
lt 1024 Patterns
! my_at_email.com Action


7
Delivering Mail with Procmail
Mail Received
Add to .inbox
8
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

9
Basic Procmail Recipes
  • Sorting Recipes
  • Forwarding Recipes
  • Program Recipes

10
Sorting Recipes
Sorting
0
Subject \UA\ If Subject contains UA
uas-mail Put it in mailbox uas-mail
  • Most common recipe used
  • Multiple patterns accepted

11
Forwarding Recipes
Forwarding
0 Header (no trailing colon)
From ksdavis If its from Kevin
! my_at_email.com Send it to my_at_email.com
  • Multiple forwarding addresses accepted
  • Multiple patterns accepted
  • To keep a copy yourself, use 0c

12
Program Recipes
Forwarding
0
Subject Survey If its for the survey
runstats.pl Run my program on it
  • Used for processing online forms
  • Very powerful proceed with caution
  • Ill talk later about 0 v. 0

13
Exercise
14
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

15
E-mail Structure
  • Two parts header and body
  • Separated by an empty line
  • Each line of header is Field Value
  • Special From line
  • Based on Berkeley mbox format

16
E-mail Structure Example
From cduan_at_fas... From line
From Aaron Lee ltlee42_at_... Header
To uas_at_fas.harvard.edu Header
Subject Interesting ... Header
Date Sun, 10 Feb 2002... Header
Blank line
I send you this file in Body
order to have your advice Body
I hope you can help me Body
  • From line separates messages

17
Regular Expressions
  • Completely compatible with egrep
  • By default, matches only header
  • Watch out for spaces
  • From cduan_at_fas Wrong
  • From cduan_at_fas Right!
  • (Thats a space and a tab in )

18
Other Special Patterns
  • ! Invert the pattern
  • ? Run a program, use the exit code
  • lt Under specified number of bytes
  • gt Over specified number of bytes
  • Evaluate quotes like /bin/sh

19
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

20
Recipe Options
  • Options placed after zero in header
  • AaEe Run based on previous recipe
  • f Change (filter) the mail
  • c Continue through this recipe
  • Read man procmailrc

21
Another Exercise
22
Using Procmail
  • What is procmail?
  • Basic procmailrc recipes
  • Using patterns
  • Recipe options
  • File locking

23
File Locking
  • Prevents procmail processes from corrupting
    mailboxes
  • Locking type depends on header
  • 0 No locking
  • 0 Default lock
  • 0 lock Lock the file lock
  • Not for forwarding, programs (?)

24
Hints and Tips
  • Test your recipes before using them
  • Resources for more information
  • man procmail, procmailrc, procmailex
  • www.procmail.org
  • Have fun using procmail!

25
The Last Blank Slide
Write a Comment
User Comments (0)
About PowerShow.com