{"id":40,"date":"2004-01-19T17:15:02","date_gmt":"2004-01-19T22:15:02","guid":{"rendered":"http:\/\/192.168.33.66\/wp\/?p=40"},"modified":"2004-01-19T17:15:02","modified_gmt":"2004-01-19T22:15:02","slug":"fetchmail-and-procmail-the-basics","status":"publish","type":"post","link":"https:\/\/wildow.com\/?p=40","title":{"rendered":"Fetchmail and Procmail &#8211; the basics"},"content":{"rendered":"<p>Fetchmail and Procmail &#8211; the basics<br \/>\nIn response to a fair few questions on these two programs (and a desire from Richard to have me do a talk on them) I&#8217;ve put together these introductory notes on the subject. <\/p>\n<p>\nhttp:\/\/ieee.uow.edu.au\/~mjp16\/misc\/fetchprocmail.html<br \/>\n<!--more--><\/p>\n<p>Fetchmail and Procmail &#8211; the basics<br \/>\nIn response to a fair few questions on these two programs (and a desire from Richard to have me do a talk on them) I&#8217;ve put together these introductory notes on the subject. <\/p>\n<p>Fetchmail<br \/>\nTakes mail from a central store (typically your ISPs mail machine) to the local system. <br \/>\nConfig file $HOME\/.fetchmailrc. Permissions must be 0600, to protect password details. <br \/>\nUse the following line for each server you&#8217;re taking mail from in your .fetchmailrc file: <br \/>\npoll <server> protocol <proto>:<br \/>\n\tuser &#8220;<username>&#8220;, with password &#8220;<pass>&#8220;, is &#8220;<local username>&#8221; here;<\/p>\n<p>The options should be filled in appropriately, as follows: <br \/>\nserver &#8211; your ISP&#8217;s mail machine, such as pop.isp.com. <br \/>\nproto &#8211; The protocol you use to pick up your mail. Usually either pop3 or imap, though the program does support many others. If you need them, you&#8217;ll know it. <br \/>\nusername &#8211; your username on the server. The double quotes help protect against any untoward characters (such as spaces and periods) which might otherwise make things unpleasant. <br \/>\npass &#8211; the password of your account on the server mail machine. This is why we set such restrictive permissions on .fetchmailrc. <br \/>\nlocal username &#8211; Your username on the local machine (where fetchmail is running). This is useful if, for instance, your ISP assigns you a username fre9kjm, when you&#8217;re known as fred on your local box. <br \/>\nTo have fetchmail run periodically whilever the link to the Internet is active, place the following line in ip-up (or equivalent): <br \/>\nsu -c <local username> &#8220;fetchmail -d 600&#8221;<\/p>\n<p>This tells fetchmail to startup and poll for mail every 600 seconds (10 minutes). Change this number for more rapid or occasional polling. <br \/>\nTo stop fetchmail again when the link goes down, place this in ip-down (or equivalent): <br \/>\nsu -c <local username> &#8220;fetchmail &#8211;quit&#8221;<\/p>\n<p>Can add &#8211;syslog to the startup command line, or set syslog to the beginning of .fetchmailrc (before any poll lines) to make all log messages go to syslog. <br \/>\nAdd &#8211;logfile <logfile> to command line or set logfile <logfile> to .fetchmailrc to log to a specified file <logfile>. <br \/>\nProcmail<br \/>\nFilters mail based on user-specified rules. <br \/>\nConfig file: $HOME\/.procmailrc <br \/>\nShould be the default local delivery agent on most Linux systems &#8211; ask the sysadmin if you&#8217;re not sure. If it isn&#8217;t, place the line <br \/>\n&#8220;|<procmail path>\/procmail&#8221;<\/p>\n<p>in your $HOME\/.forward file, replacing <procmail path> with, strangely enough, the path to the procmail binary. <br \/>\nTypical config: <br \/>\nPATH=<path of needed binaries>\nMAILDIR=<path to maildir>\nDEFAULT=<default mailbox><br \/>\nLOGFILE=<logfile><br \/>\n<filtering recipes...><\/p>\n<p>Should place in PATH only directories which you will need, to maximise security. If in doubt, have an empty path and specify full path on all binaries. <br \/>\nmaildir &#8211; likely to be $HOME\/Mail or similar. <br \/>\ndefault mailbox &#8211; where mail which doesn&#8217;t fit any filtering recipe will be put. <br \/>\nlogfile &#8211; hmm, well&#8230;. (grin) <br \/>\nRecipes<br \/>\n:0 [flags]<br \/>\n<zero or more conditions><br \/>\n<exactly one action><\/p>\n<p>Most useful flag &#8211; c &#8211; specifies that mail which matches this recipe should still be matched against the rest of the recipes, and not considered delivered. <br \/>\nIf there are multiple conditions, all must match for the action to be executed. <br \/>\nIf there are no conditions, then the recipe is always true. <br \/>\nA condition is signalled by a &#8216;*&#8217; &#8211; everything after that (except leading and trailing whitespace) is considered to be the regular expression to match against. <br \/>\nRegular expressions are a cryptic and powerful language for describing strings. Common components used are: <br \/>\n^ &#8211; start of line. <br \/>\n$ &#8211; end of line. <br \/>\n. &#8211; any single character, except newline <br \/>\n(<group>) &#8211; a group of characters (used, typically, with the options below) <br \/>\n* &#8211; 0 or more of the previous character or group. <br \/>\n+ &#8211; 1 or more of the previous character or group. <br \/>\n? &#8211; zero or one instances of the previous character or group. <br \/>\n\\ &#8211; escape the next character. <br \/>\nAny other character &#8211; itself. <br \/>\nManual pages for egrep(1) and sed(1) are also instructive for extended regular expressions. <br \/>\nEscapes are used to make an ordinarily special character match literally instead. For instance, if you wanted to match against the &#8216;$&#8217; character, then if you just placed it by itself, procmail would interpret that as &#8216;match if end of line&#8217;. Instead, we use &#8216;\\$&#8217; to match against a single &#8216;$&#8217;. <br \/>\nThere are some special procmail-specific tokens which you can use: <br \/>\n^TO &#8211; Should match any line which specifies a message recipient containing the word which follows. <br \/>\n^FROM_DAEMON &#8211; Should match on any message which was sent from an automated mail program (mailing list software, spam bot, whatever). <br \/>\nPlenty examples are available in the procmailex(5) man page. <br \/>\nReferences<br \/>\nThe Fetchmail home page <br \/>\nThe Fetchmail FAQ <br \/>\nThe procmail home page <br \/>\nMan pages: <br \/>\nfetchmail(1) <br \/>\nprocmail(1) <br \/>\nprocmailrc(5) <br \/>\nprocmailex(5) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fetchmail and Procmail &#8211; the basics In response to a fair few questions on these two programs (and a desire from Richard to have me do a talk on them) I&#8217;ve put together these introductory notes on the subject. http:\/\/ieee.uow.edu.au\/~mjp16\/misc\/fetchprocmail.html<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}