Lesson 10 | Testing filters |
Objective | Test procmail filters. |
Testing email filters in procmail
The most straightforward way to test your filters is to send email to yourself,
typing into the email the conditions you're filtering. This technique works if you're filtering an email based on its subject or contents.
You can send email to yourself from the Linux command line with the mail
command. To use it, supply your username as the first
argument, then enter the subject and body of the email. When you're finished composing the body, type a period (.
) on a line by
itself and enter any users to carbon copy, as in the example below:
[[email protected] bishop]$ mail bishop
Subject: this should be a filtered email
This email is about my credit card and making money fast!
Cc: [[email protected] /home/bishop]#
If all works as expected, you can check the filtered folder in your mail program. If the filtering didn't work as expected, then the email
will appear in your Inbox.
Note: If you receive an email that you might want
to filter, save the email and set up your filter. Then use your mail program to bounce[1] the mail
to yourself. When you bounce the mail, it will be as if you received the mail a second time, and you can check to see if your filter worked.
This is by far the best, most accurate method to test your procmail filters.
In the next lesson, you'll learn how to troubleshoot procmail.
Testing Email Filters - Exercise
[1]Bounce: To resend an email to another recipient, but retain the original email envelope. This makes an email you bounce to someone look as though he or she received it from the original sender.