The Mail::LDA 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.
It is designed primarily to work as an LDA (local
delivery agent) for an SMTP server. It should work well as the basis for a
script run from a .forward or .qmail file.
Class Mail::LDA::DeliveryReject
Class Mail::LDA::DeliveryComplete
Class Mail::LDA::DeliveryPipeFailure
Class Mail::LDA::DeliverySuccess
Class Mail::LDA::LoggingError
Class Mail::LDA::DeliveryDefer
Included modules
Create a new Mail::LDA object.
input may be a Mail::Message
object (in which case, it is used directly). Otherwise, it is passed to
Mail::Message.new and used to create a
new Mail::Message object.
log may be nil (to disable logging completely) or a file name to
which log messages will be appended.
Takes the same input as #new, but passes
the created Mail::LDA to the supplied block.
The idea is that the entire delivery script is contained within the block.
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.
Expected use:
begin
Mail::LDA.process(stdin, "my-log-file") { |lda|
# ...code uses lda to deliver mail...
}
rescue Mail::LDA::DeliveryComplete => exception
exit(Mail::LDA.exitcode(exception))
rescue Exception
... perhaps log the exception to a hard coded file ...
exit(Mail::MTA::EX_TEMPFAIL)
end
This function expects the exception argument to be a Mail::LDA::DeliveryComplete subclass.
The function will return the appropriate exitcode that the process should
exit with.
Save this message to mail folder. folder must be the file name of
the mailbox. If folder ends in a slash (/) then the mailbox will be
considered to be in Maildir format, otherwise it will be a Unix mbox folder.
If continue is false (the default), a Mail::LDA::DeliverySuccess
exception is raised upon successful delivery. Otherwise, the method simply
returns upon successful delivery.
Upon failure to deliver, the function raises a Mail::LDA::DeliveryPipeFailure
exception.
See also: Mail::Deliver.deliver_mbox and Mail::Deliver.deliver_maildir.
Reject this message for now, but request that it be queued for re-delivery
in the future. Logs the reason for the rejection and raises a
Mail::LDA::DeliveryDefer
exception.
Pipe this message to a command. command must be a string specifying
a command to pipe the message to.
If continue is false, then a successful delivery to the pipe will
raise a Mail::LDA::DeliverySuccess
exception. If continue is true, then a successful delivery will
simply return. Regardless of continue, a failure to deliver to the
pipe will raise a Mail::LDA::DeliveryPipeFailure
exception.
See also: Mail::Deliver.deliver_pipe.
Log a string to the log. If the current log is nil or level is
greater than the current logging level, then the string will not be logged.
See also #logging_level, #logging_level=
Set the current logging level. The level must be a number no less
than one.
See also: #logging_level, #log
Return the header of the message as a Mail::Header object. This is short hand for
lda.message.header.
See also: #message, #body
Return the body of the message as an array of strings. This is short hand
for lda.message.body.
See also: #message, #header
|