A lockfile is necessary to prevent problems if 2 or more instances of procmail are working at the same time that may happen if 2 or more email arrive almost at the same moment. An action can also start with a pipe, which means the message is going to be passed to the standard input of the command following the pipe.
For example:. If the f flag was used, the command can alter the message and keep reading recipes. In this example, the SpamAssassin command will add headers to the mail, with its spam status level, which later can be used by another recipe to block it, or store it on a different mailbox.
Here is an example using SpamAssassin to block spam. You should already have SpamAssassin installed and working. If a coworker keeps using forward to send you jokes and other non serious stuff, but at the same time, writes you work related mails, you could save the forwarded mails most likely not-work-related mails on a different mailbox. Depends on your MUA. Some mark as read by adding a header, some encode it in the file name if you are using maildir, try adding a "," to the end of the file name I think it was comma , others have a secret index somewhere which is hard to access from outside the MUA.
Add a comment. Active Oldest Votes. Note: Updated dec. The example below marks new emails as read but also unread old messages. The manual states the following: The exception statement traps errors that would normally cause maildrop to terminate.
I was searching for a maildrop filter when I found your question. But for maildrop I found an elaborate explanation here — drumfire. Regarding the procmail solution, some explanations would be helpful. For example, the regex is particularly cryptic, as is the renaming operation which effectively marks the message as read. Delivering to MH folders is slightly more time consuming than delivering to normal directories or mailboxes, because procmail has to search for the next available number instead of having the filename immediately available.
When delivering the mail, line breaks will appear as before. They are sent off once when procmail generates the regular logfile entry. Procmail is NFS-resistant and eight-bit clean.
Be sure to include the single and double quotes, and unless you know your site to be running smrsh the SendMail Restricted SHell , it must be an absolute path. If you would like to stay informed about new versions and official patches send a subscription request to procmail-announce-request procmail. Procmail will print its version number, display its compile time configuration and exit.
Preserve any old environment. Make procmail fail softly, i. Assume traditional Berkeley mailbox format, ignore any Content-Length: fields. Turns procmail into a general purpose mail filter. The maildir folder "x" is missing one or more required subdirectories and procmail could not create them. Lockfile was already gone, or write permission to the directory where the lockfile is has been denied. Procmail will not take on the identity that comes with the rcfile because a security violation was found e.
As procmail was started, stdin, stdout or stderr was not connected possibly an attempt to subvert security. No write permission in the directory where lockfile "x" resides, or more than one procmail trying to force a lock at exactly the same time.
Procmail either needs root privileges, or must have the right e uid and e gid to run in delivery mode. The regular expression "x" contains errors most likely some missing or extraneous parens.
While trying to use the kernel-supported locking calls, one of them failed usually indicates an OS error , procmail ignores this error and proceeds. Can only occur if you specify some real weird and illegal lockfilenames or if the lockfile could not be created because of insufficient permissions or nonexistent subdirectories. Procmail tried to clone itself but could not find back rcfile "x" it either got removed or it was a relative path and you changed directory since procmail opened it last time.
You specified the -m option, procmail expects the name of an rcfile as argument. You specified the -d option or called procmail under a different name, it expects one or more recipients as arguments. The filesystem containing "x" does not have enough free space to permit delivery of the message to the file. The filesize quota for the recipient on the filesystem containing "x" does not permit delivering the message to the file.
The system mailbox of the recipient was found to be bogus, procmail performed evasive actions. Timeout has occurred on program, filter or file "x". Either the suffix on "x" would indicate that it should be an MH or maildir folder, or it was listed as an second folder into which to link, but it already exists and is not a directory. The mail spool directory was not accessible to procmail, it relied solely on kernel locks. The name of that file will be based on several rather complicated factors that you don't have to worry about unless you use the Rand MH system, or some other relatively obscure and "exotic" mail agent.
This is a simple one consisting of no flags, one condition and a simple file delivery. It simply throws away any mail from "someone I don't like. This consists of a set of negative conditions notice that the conditions all start with the '! This means: for any mail that didn't come from a " daemon " some automated process and didn't come a " mailer " some other automated process and which doesn't contain any header line of the form: " X-Loop: myadd I can put the script directly in the rc file which is what most procmail users do most of the time.
This script might do anything to the mail. In this case -- whatever it does had better be good because procmail way will consider any such mail to be delivered and any recipes after this will only be reached by mail from DAEMON s, MAILER s and any mail with that particular X-Loop: line in the header. The X-Loop: line is a normal procmail condition. In the RFC document which defines what e-mail headers should look like on the Internet any line started with X- is a "custom" header.
This means that any mail program that wants to can add pretty much any X- line it wants. A common procmail idiom is to add an X-Loop: line to the header of any message that we send out -- and to check for our own X-Loop: line before sending out anything.
This is to protect against "mail loops" -- situations where our mail gets forwarded or "bounced" back to us and we endlessly respond to it. So, here's a detailed example of how to use procmail to automatically respond to mail from a particular person. We start with the recipe header. FROM is a "magic" value for procmail -- it checks from, resent-by, and similar header lines.
There are slight differences in "regex" syntax for each application. However the man page for ' grep ' or ' egrep ' is an excellent place to learn more. These are a couple more "magic" values. The man pages show the exact regexes that are assigned to these keywords -- if you're curious or need to tweak a special condition that is similar to one or the other of these.
The 'bang' in this case and most other regex contexts "negates" or "reverses" the meaning of the pattern.
0コメント