filter 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. .TH FILTER 1
  2. .SH NAME
  3. filter, list, deliver, token, vf \- filtering mail
  4. .SH SYNOPSIS
  5. .PP
  6. .B upas/filter
  7. [
  8. .B -bh
  9. ]
  10. .I rcvr
  11. .I mailbox
  12. .I "regexp file
  13. [
  14. .I "regexp file
  15. ]*
  16. .PP
  17. .B upas/list add|check
  18. .I patterns
  19. .I addrfile ...
  20. .PP
  21. .B upas/deliver
  22. .I recipient
  23. .I fromfile
  24. .I mbox
  25. .PP
  26. .B upas/token
  27. .I key
  28. [
  29. .I tokenfile
  30. ]
  31. .PP
  32. .B upas/vf
  33. .SH DESCRIPTION
  34. .PP
  35. A user may filter all incoming mail by creating
  36. a world readable/executable file
  37. .BI /mail/box/ username /pipeto.
  38. If the file is a shell script, it can use the
  39. commands described here to implement a filter.
  40. .PP
  41. .I Filter
  42. provides simple mail filtering.
  43. The first two arguments are the recipient's address and mailbox, that is,
  44. the same arguments provided to
  45. .BR pipeto .
  46. The remaining arguments are all pairs of a regular expression and a file name.
  47. With no flags, the sender's address is matched against each
  48. regular expression starting with the first. If the expression
  49. matches, then the message is delivered to the file whose name
  50. follows the expression. The file must be world writable and should
  51. be append only.
  52. A message that matches none of the expressions is delivered into
  53. the user's standard mail box.
  54. The flags are:
  55. .TP
  56. .B h
  57. the regular expression is matched against the message header
  58. rather than the address.
  59. .TP
  60. .B b
  61. the regular expression is matched against both the header and the body
  62. of the message.
  63. .PP
  64. For example, to delete any messages of precedence bulk, place in
  65. your
  66. .B pipeto
  67. file:
  68. .EX
  69. /bin/upas/filter -h $1 $2 'Precedence: bulk' /dev/null
  70. .EE
  71. .PP
  72. Three other commands exist which, combined by an
  73. .IR rc (1)
  74. script, allow you to build your own filter.
  75. .PP
  76. .I List
  77. takes two verbs;
  78. .B check
  79. and
  80. .BR add .
  81. .B Check
  82. directs
  83. .I list
  84. to check each address contained in the
  85. .IR addressfile s
  86. against a list of patterns in
  87. .IR patternfile .
  88. Patterns come in four forms:
  89. .TP
  90. .B ~\fIregular-expression\fP
  91. If any address matches the regular expression,
  92. .I list
  93. returns successfully.
  94. .TP
  95. .BR =\fIstring\fP .
  96. If any address exactly matches
  97. .IR string ,
  98. .I list
  99. returns successfully.
  100. .TP
  101. .B !~\fIregular-expression\fP
  102. If any address matches the regular expression
  103. and no other address matches a non `!' rule,
  104. .I list
  105. returns error status "!match".
  106. .TP
  107. .B !=\fIstring\fP
  108. If any address exactly matches
  109. .I string
  110. and no other address matches a non `!' rule,
  111. .I list
  112. returns error status "!match".
  113. .PP
  114. If no addresses match a pattern,
  115. .I list
  116. returns "no match".
  117. .PP
  118. The pattern file may also contain lines of the form
  119. .EX
  120. #include filename
  121. .EE
  122. This allows pattern files to include other pattern
  123. files.
  124. All pattern matches are case insensitive.
  125. .I List
  126. searches the pattern file (and its includes) in order.
  127. The first matching pattern determines the action.
  128. .PP
  129. .I List
  130. .B add
  131. directs
  132. .I list
  133. to add a pattern to
  134. .I patternfile
  135. for each address in the
  136. .IR addrssfile 's
  137. that doesh't already match a pattern.
  138. .PP
  139. .IR Token ,
  140. with only one argument, prints to standard output a unique token
  141. created from the current date and
  142. .IR key .
  143. With two arguments, it checks
  144. .I token
  145. against tokens created over the last 10 days with
  146. .IR key .
  147. If a match is found, it returns successfully.
  148. .PP
  149. .I Deliver
  150. delivers into mail box
  151. .I mbox
  152. the message read from standard input.
  153. It obeys standard mail file locking and logging
  154. conventions.
  155. .PP
  156. A sample
  157. .B pipeto
  158. using the filter kit can be found in
  159. .BR /sys/src/cmd/upas/filterkit/pipeto.sample .
  160. .PP
  161. A sample
  162. .BR pipefrom ,
  163. .BR /sys/src/cmd/upas/filterkit/pipefrom.sample ,
  164. is provided which adds all addresses of your outgoing
  165. mail to your pattern file.
  166. You should copy it into a directory that normally gets
  167. bound by your profile onto
  168. .BR /bin .
  169. .PP
  170. .I Vf
  171. takes a mail message as standard input, searches for executable
  172. MIME attachments, wraps them in a warning message, and appends
  173. .B .suspect
  174. to any related filenames.
  175. .B /sys/lib/mimetype
  176. contains the list of known MIME content types and file extensions.
  177. .I Vf
  178. considers all those for which the fifth field of
  179. .B mimetype
  180. is
  181. .BR n .
  182. If the script
  183. .B /mail/lib/validateattachment
  184. exists and is executable, each attachment
  185. is passed, as a mail message, to the script
  186. for further examination.
  187. .SH FILES
  188. .TF /mail/box/*/dead.letter
  189. .TP
  190. .B /mail/box/*/pipeto
  191. mail filter
  192. .TP
  193. .B /sys/lib/mimetype
  194. mime content types
  195. .TP
  196. .B /mail/lib/validateattachment
  197. attachment checker
  198. .SH SOURCE
  199. .TP
  200. .B /sys/src/cmd/upas/send
  201. .TP
  202. .B /sys/src/cmd/upas/filterkit
  203. .TP
  204. .B /sys/src/cmd/upas/vf
  205. .SH "SEE ALSO"
  206. .IR aliasmail (8),
  207. .IR faces (1),
  208. .IR mail (1),
  209. .IR marshal (1),
  210. .IR mlmgr (1),
  211. .IR nedmail (1),
  212. .IR qer (8),
  213. .IR rewrite (6),
  214. .IR send (8),
  215. .IR smtp (8),
  216. .IR upasfs (4)