1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: RFilter::DeliveryAgent</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel=StyleSheet href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript" language="JavaScript">
<!--
function popCode(url) {
window.open(url, "Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
//-->
</script>
</head>
<body bgcolor="white">
<table summary="Information on class" width="100%" border="0" cellspacing="0">
<tr class="title-row">
<td class="big-title-font">
<sup><font color="aqua">Class</font></sup> RFilter::DeliveryAgent
</td>
<td align="right">
<table summary="layout" cellspacing="0" cellpadding="2">
<tr valign="top">
<td class="small-title-font">In:</td>
<td class="small-title-font">
<a href="../../files/lib/rfilter/delivery_agent_rb.html" class="aqua">
lib/rfilter/delivery_agent.rb
</a>
<br />
</td>
</tr>
<tr>
<td class="small-title-font">Parent:</td>
<td class="small-title-font">
Object
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- banner header -->
<div class="description"><p>
The <a href="DeliveryAgent.html">RFilter::DeliveryAgent</a> class allows
flexible delivery of a mail message to a mailbox. It is designed to make
mail filtering scripts easy to write, by allowing the filter author to
concentrate on the filter logic and not the particulars of the message or
folder format.
</p>
<p>
It is designed primarily to work as an <a
href="DeliveryAgent.html">DeliveryAgent</a> (local delivery agent) for an
SMTP server. It should work well as the basis for a script run from a
.forward or .qmail file.
</p>
</div>
<table summary="Methods" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Methods</td></tr>
</table>
<div class="name-list">
<a href="#M000041">body</a>
<a href="#M000032">defer</a>
<a href="#M000043">exitcode</a>
<a href="#M000034">filter</a>
<a href="#M000040">header</a>
<a href="#M000035">log</a>
<a href="#M000036">logging_level</a>
<a href="#M000037">logging_level=</a>
<a href="#M000038">message</a>
<a href="#M000039">message=</a>
<a href="#M000029">new</a>
<a href="#M000033">pipe</a>
<a href="#M000042">process</a>
<a href="#M000031">reject</a>
<a href="#M000030">save</a>
</div>
<table summary="List of classes" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Classes and Modules</td></tr>
</table>
<div class="classlist">
Class <a href="DeliveryAgent/DeliveryCommandFailure.html" class="link">RFilter::DeliveryAgent::DeliveryCommandFailure</a><br />
Class <a href="DeliveryAgent/DeliveryComplete.html" class="link">RFilter::DeliveryAgent::DeliveryComplete</a><br />
Class <a href="DeliveryAgent/DeliveryDefer.html" class="link">RFilter::DeliveryAgent::DeliveryDefer</a><br />
Class <a href="DeliveryAgent/DeliveryReject.html" class="link">RFilter::DeliveryAgent::DeliveryReject</a><br />
Class <a href="DeliveryAgent/DeliverySuccess.html" class="link">RFilter::DeliveryAgent::DeliverySuccess</a><br />
Class <a href="DeliveryAgent/LoggingError.html" class="link">RFilter::DeliveryAgent::LoggingError</a><br />
</div>
<table summary="Included modules" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Included modules</td></tr>
</table>
<div class="name-list">
<span class="method-name"><a href="Deliver.html">RFilter::Deliver</a></span>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Class methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000029"></a>
<a href="DeliveryAgent.src/M000029.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000029.html');return false;">
<b>new</b>(input, logfile)
</a>
</td></tr>
</table>
<div class="description">
<p>
Create a new <a href="DeliveryAgent.html">RFilter::DeliveryAgent</a>
object.
</p>
<p>
<tt>input</tt> may be a RMail::Message object (in which case, it is used
directly). Otherwise, it is passed to RMail::Message.new and used to create
a new RMail::Message object.
</p>
<p>
<tt>log</tt> may be nil (to disable logging completely) or a file name to
which log messages will be appended.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000042"></a>
<a href="DeliveryAgent.src/M000042.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000042.html');return false;">
<b>process</b>(input, logfile) {|lda| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Takes the same input as <a href="AddressTagger.html#M000050">#new</a>, but
passes the created <a href="DeliveryAgent.html">RFilter::DeliveryAgent</a>
to the supplied block. The idea is that the entire delivery script is
contained within the block.
</p>
<p>
This function tries to log exceptions that aren’t DeliveryComplete
exceptions to the lda’s log. If it can log them, it defers the
delivery. But if it can’t, it re-raises the exception so the caller
can more properly deal with the exception.
</p>
<p>
Expected use:
</p>
<pre>
begin
RFilter::DeliveryAgent.process(stdin, "my-log-file") { |lda|
# ...code uses lda to deliver mail...
}
rescue RFilter::DeliveryAgent::DeliveryComplete => exception
exit(RFilter::DeliveryAgent.exitcode(exception))
rescue Exception
... perhaps log the exception to a hard coded file ...
exit(RFilter::MTA::EX_TEMPFAIL)
end
</pre>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000043"></a>
<a href="DeliveryAgent.src/M000043.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000043.html');return false;">
<b>exitcode</b>(exception)
</a>
</td></tr>
</table>
<div class="description">
<p>
This function expects the <tt>exception</tt> argument to be a <a
href="DeliveryAgent/DeliveryComplete.html">RFilter::DeliveryAgent::DeliveryComplete</a>
subclass. The function will return the appropriate exitcode that the
process should exit with.
</p>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Instance methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000030"></a>
<a href="DeliveryAgent.src/M000030.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000030.html');return false;">
<b>save</b>(folder, continue = false)
</a>
</td></tr>
</table>
<div class="description">
<p>
Save this message to mail folder. <tt>folder</tt> must be the file name of
the mailbox. If <tt>folder</tt> ends in a slash (/) then the mailbox will
be considered to be in Maildir format, otherwise it will be a Unix mbox
folder.
</p>
<p>
If <tt>continue</tt> is false (the default), a <a
href="DeliveryAgent/DeliverySuccess.html">RFilter::DeliveryAgent::DeliverySuccess</a>
exception is raised upon successful delivery. Otherwise, the method simply
returns upon successful delivery.
</p>
<p>
Upon failure, the function raises an exception as determined by <a
href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000016">deliver_mbox</a> or <a
href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000020">deliver_maildir</a>.
</p>
<p>
See also: <a href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000016">deliver_mbox</a> and <a
href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000020">deliver_maildir</a>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000031"></a>
<a href="DeliveryAgent.src/M000031.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000031.html');return false;">
<b>reject</b>(reason = nil)
</a>
</td></tr>
</table>
<div class="description">
<p>
Reject this message. Logs the <tt>reason</tt> for the rejection and raises
a <a
href="DeliveryAgent/DeliveryReject.html">RFilter::DeliveryAgent::DeliveryReject</a>
exception.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000032"></a>
<a href="DeliveryAgent.src/M000032.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000032.html');return false;">
<b>defer</b>(reason = nil)
</a>
</td></tr>
</table>
<div class="description">
<p>
Reject this message for now, but request that it be queued for re-delivery
in the future. Logs the <tt>reason</tt> for the rejection and raises a <a
href="DeliveryAgent/DeliveryDefer.html">RFilter::DeliveryAgent::DeliveryDefer</a>
exception.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000033"></a>
<a href="DeliveryAgent.src/M000033.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000033.html');return false;">
<b>pipe</b>(command, continue = false)
</a>
</td></tr>
</table>
<div class="description">
<p>
Pipe this message to a command. <tt>command</tt> must be a string
specifying a command to pipe the message to.
</p>
<p>
If <tt>continue</tt> is false, then a successful delivery to the pipe will
raise a <a
href="DeliveryAgent/DeliverySuccess.html">RFilter::DeliveryAgent::DeliverySuccess</a>
exception. If <tt>continue</tt> is true, then a successful delivery will
simply return. Regardless of <tt>continue</tt>, a failure to deliver to the
pipe will raise a <a
href="DeliveryAgent/DeliveryCommandFailure.html">RFilter::DeliveryAgent::DeliveryCommandFailure</a>
exception.
</p>
<p>
See also: <a href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000018">deliver_pipe</a>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000034"></a>
<a href="DeliveryAgent.src/M000034.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000034.html');return false;">
<b>filter</b>(*command)
</a>
</td></tr>
</table>
<div class="description">
<p>
Filter this message through a command. <tt>command</tt> must be a string or
an array of strings specifying a command to filter the message through (it
is passed to the Kernel::exec method).
</p>
<p>
If the command does not exit with a status of 0, a <a
href="DeliveryAgent/DeliveryCommandFailure.html">RFilter::DeliveryAgent::DeliveryCommandFailure</a>
exception is raised and the current message is not replaced.
</p>
<p>
See also: <a href="Deliver.html">RFilter::Deliver</a>.<a
href="Deliver.html#M000019">deliver_filter</a>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000035"></a>
<a href="DeliveryAgent.src/M000035.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000035.html');return false;">
<b>log</b>(level, str)
</a>
</td></tr>
</table>
<div class="description">
<p>
Log a string to the log. If the current log is nil or <tt>level</tt> is
greater than the current logging level, then the string will not be logged.
</p>
<p>
See also <a href="DeliveryAgent.html#M000036">#logging_level</a>, <a
href="DeliveryAgent.html#M000037">#logging_level=</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000036"></a>
<a href="DeliveryAgent.src/M000036.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000036.html');return false;">
<b>logging_level</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the current logging level.
</p>
<p>
See also: <a href="DeliveryAgent.html#M000037">#logging_level=</a>, <a
href="DeliveryAgent.html#M000035">#log</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000037"></a>
<a href="DeliveryAgent.src/M000037.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000037.html');return false;">
<b>logging_level=</b>(level)
</a>
</td></tr>
</table>
<div class="description">
<p>
Set the current logging level. The <tt>level</tt> must be a number no less
than one.
</p>
<p>
See also: <a href="DeliveryAgent.html#M000036">#logging_level</a>, <a
href="DeliveryAgent.html#M000035">#log</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000038"></a>
<a href="DeliveryAgent.src/M000038.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000038.html');return false;">
<b>message</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the RMail::Message object associated with this <a
href="DeliveryAgent.html">RFilter::DeliveryAgent</a>.
</p>
<p>
See also: <a href="DeliveryAgent.html#M000040">#header</a>, <a
href="DeliveryAgent.html#M000041">#body</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000039"></a>
<a href="DeliveryAgent.src/M000039.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000039.html');return false;">
<b>message=</b>(message)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the message (which should be a RMail::Message object) that we’re
delivering.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000040"></a>
<a href="DeliveryAgent.src/M000040.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000040.html');return false;">
<b>header</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the header of the message as a RMail::Header object. This is short
hand for lda.message.header.
</p>
<p>
See also: <a href="DeliveryAgent.html#M000038">#message</a>, <a
href="DeliveryAgent.html#M000041">#body</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000041"></a>
<a href="DeliveryAgent.src/M000041.html" target="Code" class="methodtitle"
onClick="popCode('DeliveryAgent.src/M000041.html');return false;">
<b>body</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the body of the message as an array of strings. This is short hand
for lda.message.body.
</p>
<p>
See also: <a href="DeliveryAgent.html#M000038">#message</a>, <a
href="DeliveryAgent.html#M000040">#header</a>
</p>
</div>
</body>
</html>
|