Incoming Queuing MTA kicks off a fml process. It reads a message from STDIN. The fml process reads a message once and write it onto the hard disk (write it into the incoming queue). After the queuing succeeded, the process starts to analyze a message. For this logic, the original mail is saved before main processing starts. If the queuing fails, fml calls exit(EX_TEMPFAIL). In almost cases, exit(75). If MTA receives this exit code, MTA tries to deliver again later. Mail::Delivery::Queue class processes the incoming queue. The queus is removed when the process ends. fml Sends Back A Mail Message Mail::Delivery::Queue class inserts a message to send back into the mail queue. Later FML::Process::QueueManager handles the real delivery process. Article delivery processing is a little diffferent but based on queueing by Mail::Delivery::Queue. If someting error occurs in delivery, another fml process tries to deliver it later. Coding In &fml8; Sources. Code is like this to send back a message: $curproc->reply_message( "you are not a ML member." ); If no recipient specified, the recipient is the sender of the message (From: address). To send a file, like this: $curproc->reply_message( { type => "text/plain; charset=iso-2022-jp", path => "/etc/fml/main.cf", filename => "main.cf", disposition => "main.cf example", }); $curproc->reply_message( { type => "image/gif", path => "/some/where/logo001.gif", filename => "logo.gif", disposition => "attachment", }); Mail Queue And Delivery System FML::Process::QueueManager picks up one queue from the queue directory. Mail::Message parses it. Mail::Delivery processes the real delivery via FML::Mailer. Mail::Delivery::Queue | | ---> queue directory V FML::Process::QueueManager | | <--- queue directory V FML::Mailer | V Mail::Delivery In manipulating queue, we should lock the target queue by flock(2). Mail Queue Directory The queue directory consists of the following plural directories: new/ active/ incoming/ deferred/ info/sender/ info/recipients/ info/transport/ info/ stores envelope information. incoming/ holds incoming queue, others hold outgoing information. In creating a new outgoing queue file, make a temporary file in new/ once. When the delivery preparation is ended, move the queue from new/ to active/. Hence files under active/ is delivery ready. Lock The Queue When we need to handle the specific queue file, use lock()/unlock() method for each $queue_id object. The lock algorithm is based on flock(2) for the file.