Using Procmail   «Prev  Next»

Lesson 7Recipe actions
ObjectiveDescribe recipe actions.

Maildrop Action Lines

Question: Are there any action lines in maildrop to process the email?
Yes, in maildrop, there are "action lines" that can be used to process incoming email messages. These lines specify what should be done with the message, such as delivering it to a particular folder or mailbox, filtering out spam or unwanted messages, or forwarding it to another address.
Here are a few examples of action lines in maildrop:
  1. To deliver a message to a specific folder: to $HOME/Maildir/foldername
  2. To filter out messages from a particular sender:
    if (/^From:.*[email protected]:/) { 
    # Filter out annoying sender exit 
    }
    
  3. To forward a message to another email address:
    forward [email protected]
    

These are just a few examples, but there are many more actions that can be performed using maildrop. The specific actions and syntax used may depend on the email system and configuration being used.

Recipe Actions for procmail

Action lines, which are the last lines in a recipe, tell procmail how to process the email. procmail can manipulate an email in several ways, illustrated in the following slide show.
Lines that begin with a colon indicate the start of a recipe.
1) Lines that begin with a colon indicate the start of a recipe.

This line starts a recipe that searches both the header and body of the email.
2) This line starts a recipe that searches both the header and body of the email.

This condition matches any email that has
3) This condition matches any email that has "From:" at the start of the line, followed somewhere by "[email protected]". This condition intends to catch email from Mom.

This action line stores any mail from Mom in the personal/Mom-mail folder. personal/ is a directory that holds the actual Mom-mail mailbox. If this mail folder doesn't already exist, procmail will create it and add the mail to it. If the folder already exists, procmail will append the mail onto the mailbox's end. You should always specify a colon (:) on the end.
4) This action line stores any mail from Mom in the personal/Mom-mail folder. personal/ is a directory that holds the actual Mom-mail mailbox. If this mail folder doesn't already exist, procmail will create it and add the mail to it. If the folder already exists, procmail will append the mail onto the mailbox's end. You should always specify a colon (:) on the end.

This condition matches any email from the spam.com domain
5) This condition matches any email from the spam.com domain

This action stores the mail in /dev/null, or the system trash can.
6) This action stores the mail in /dev/null, or the system trash can.

This condition matches any subject that has 'system intrusion detected' in it.
7) This condition matches any subject that has 'system intrusion detected' in it.

This action sends the message to the page.admin@pager.net email address
8) This action sends the message to the [email protected] email address

This condition looks for the text 'quarterly reports'.
9) This condition looks for the text 'quarterly reports'.

This action sends the message to the /usr/local/bin/reporter program. The program should be configured to read input from standard input.
10) This action sends the message to the /usr/local/bin/reporter program. The program should be configured to read input from standard input.

If you use mh as your Mail User Agent (MUA), then append /. onto the end of the mailbox's name. Doing so will instruct procmail to save the message in mh-specific format.
Mail User Agents (MUA): Programs responsible for displaying and composing email.
Consult the procmailrc man page for more examples and advanced actions. In the next lesson, you'll learn how to invoke procmail.

maildrop is compatible with the latest version of Red Hat Linux

Question: Can maildrop be used with the latest version of Red Hat Linux?
Yes, maildrop can be used with the latest version of Red Hat Linux, as well as with many other Linux distributions. Maildrop is a popular mail delivery agent that can be used with a variety of email systems and servers. It is typically installed on the mail server itself and is responsible for delivering incoming email messages to the appropriate mailboxes or folders.
To use maildrop with Red Hat Linux, you will need to install the maildrop package, which is available through the Red Hat Package Manager (RPM). Once installed, you can configure maildrop to work with your email system and specify the appropriate actions to be taken for incoming messages. The specific steps for installing and configuring maildrop may vary depending on your specific setup and email system, but there are many resources and tutorials available online to help guide you through the process.

Recipe Actions - Exercise

Before you move to the next lesson, click the Exercise link below to test your understanding of recipe flags, conditions and actions.
Recipe Actions - Exercise

SEMrush Software 7 SEMrush Banner 7