|
THE RECIPE LIST
|
|
|
Forwarding Email to One Address - forwards a copy of the incoming email to the address emailaddy@example.com. Standard delivery is not affected, so the email will still be delivered to the original recipient as well.
forward emailaddy@example.com
|
Forwarding Email to a List of Addresses - forwards the incoming email to each of the addresses in the list (in this case, 2 addresses). Standard delivery is not affected, so the email will still be delivered to the original recipient as well.
forward emailaddy@example.com email2@example.net
|
Conditional Forwarding - This is an example of forwarding only if the email is sent from a particular address. In any case, the email is still delivered to the original mailbox. If the "From" address matches match@example.com, a copy of the email is also forwarded to forward@example.com.
if 822field from | grep -iq "match@example.com"; then forward forward@example.com; fi
|
|
|
Redirecting an Email: General Format - redirects incoming email to forward@example.com if the test program is "true". Otherwise, delivery of the email continues as normal. Examples of various test programs are located below.
condredirect forward@example.com testprogram
|
Redirecting an Email Based on the To or Cc Address - redirects incoming email to forward@example.com if either the To or Cc fields in the message headers contain the address match@example.com
condredirect forward@example.com iftocc match@example.com
|
Redirecting an Email From a Particular Address - redirects incoming email to forward@example.com if the From field in the message headers contains the address match@example.com
Note: the following filter should be on a single line.
condredirect forward@example.com sh -c '822field from | grep -iq match@example.com'
|
Redirecting an Email Based on Subject - searches the Subject field in the message headers for a particular word or phrase from a list in a textfile. If there is a match, the email is redirected to forward@example.com. Otherwise, the message is delivered normally.
Sample file is saved as /big/dom/xdomain/badsubj.txt with the following contents:
dvd
cell phone
viagra
low rates
increase your hits
mortgage |
then the filter would be (on a single line):
condredirect forward@example.com sh -c '822field subject | grep -qiFf "/big/dom/xdomain/badsubj.txt"'
Note:
The -f switch let's you read from file.
The -F takes each phrase, one on a line, as a literal string to match, not a regex.
The -i switch makes the match case insensitive.
|
|
|
Deleting an Email: General Format - Runs a test program and if this evaluates to "true", then deletes the email. Sample test programs are given in the examples that follow. This is simply a Bash shell script using an "if" test.
CAUTION: Deleted email cannot be recovered. If you cannot risk losing email, then we suggest using the Redirect options described above to redirect email to a local POP mailbox and then review it manually for false positives.
if test program; then exit 99; fi
|
Deleting Email From a Particular Sender - checks the From header of an incoming email for the email address sender@example.com. If it matches, the email is deleted and not delivered to the mailbox.
if 822field from | grep -iq "sender@example.com"; then exit 99; fi
|
Deleting Email From a Sender in a List - checks the From header of an incoming email to see if the email address matches any addresses or domains in a textfile. If a match is found, delete the email and do not deliver it to the mailbox.
Sample file is saved as /big/dom/xdomain/badfrom.txt with the following contents:
then the following filter would be (all on one line):
if 822field from | grep -qiFf "/big/dom/xdomain/badfrom.txt"; then exit 99; fi
Note:
The -f says to read the patterns from the file.
The -F says to treat the patterns as text, not as regular expressions.
|
Deleting Email Sent Bcc - checks whether any email addresses of the email header fields such as To: or Cc: match one in a list of addresses. If not, deletes the email and doesn't deliver it to the email address.
if ! iftocc me@domain.tld me@example.com me@hotmail.com; then exit 99; fi
|
|
|
Test Message Header Field for Content - checks whether the message header called fieldname contains the word matchword. If there is a match, returns "true" as an exit code of zero.
sh -c '822field fieldname | grep -qi matchword'
|
Test Message Header Field for Content from a List - checks whether the message header called fieldname contains any word or phrase from the file matchfile.txt where each word or phrase appears on a separate line in the file. If there is a match, returns "true" as an exit code of zero.
Sample file is saved as /big/dom/xdomain/matchfile.txt with the following contents:
dvd
cell phone
viagra
low rates
increase your hits
mortgage |
Note: the following filter should be on a single line.
sh -c '822field fieldname | grep -qiFf "/big/dom/xdomain/matchfile.txt"'
|
Test the Size of a Message - checks whether a message exceeds a certain size in bytes. If so, returns "true" as an exit code of zero, otherwise returns a non-zero exit code (i.e. "false"). In the below example, tests for a message greater than 1,000,000 bytes. This filter is also available as a Built-in filter in the CNC.
usage: /usr/local/fqdeliver/tests/msg-size bytes
Example usage: /usr/local/fqdeliver/tests/msg-size 1000000
|
Test for Particular File Attachments - checks for file attachments that end in a particular extension. If the incoming email has an attached file with one of the listed extensions, this test returns "true" as an exit code of zero, otherwise it returns a non-zero exit code (i.e. "false"). File extensions are passed to the command as arguments. This filter is also available as a Built-in filter in the CNC.
Example usage: /usr/local/fqdeliver/tests/no-ext mpg gif
|
Additional Tests in /usr/local/fqdeliver/tests - a number of tests are available in this directory. Here is a list with brief descriptions. They can be used similarly to the test for Message Size and the test for Particular File Attachments, as shown above.
- no-attachment - exits true if the message has an attachment.
- no-exe - exits true if the message has an attachment with an executable filename extension. This is also available as a Built-in filter in the CNC. For more information, see the Built-in filter section of the "Email Filters - An Overview" tutorial.
- received-ip - exits true if the message arrived from one of the listed IPs. IPs are listed as arguments of the command. Also available as a Built-in filter in the CNC.
- recipient - exits true if the envelope recipient matches a specified email address, passed to the command as an argument. The envelope recipient address is the email address in a Delivered-To header, not in the To or CC header. Also available as a Built-in filter in the CNC.
- sender - exits true if the SMTP envelope sender matches one of the listed email addresses, passed to the command as an argument. Also available as a Built-in filter in the CNC.
|