The numbered explanatory text that follows corresponds to the numbered comments in Example 4–1:
To start the dequeue processing, mtaDequeueStart() is called, and it calls process_message(), which processes each queued message. Since process_message() uses stdout for its output, only one message can be processed at a time. To effect that behavior, mtaDequeueStart() is called with the MTA_THREAD_MAX_THREADS set to one.
If the call to mtaDequeueStart() succeeds, the program exits normally.
If the call to mtaDequeueStart() fails, a diagnostic error message is displayed and the program exits with an error status.
process_message() is called by mtaDequeueStart() for each queued message.
The private context in process_message() tracks whether or not this is the first time the routine has been called. On the first call, the memory pointed at by my_ctx_2 is guaranteed to be NULL.
The routine obtains each envelope recipient address, one at a time, using calls to mtaDequeueRecipientNext().
Each recipient is marked as delivered using mtaDequeueRecipientDispostion(). An actual channel program would typically not make this call until after processing the message further.
If process_message() returns without first dequeuing the message, mtaDequeueStart() defers the message for a later delivery attempt.
The routine calls mtaDequeueLineNext() to read the message header and body, one line at a time. When there are no more lines to read, mtaDequeueLineNext() returns a status of MTA_EOF. When a line is read successfully, mtaDequeueLineNext() returns a status of MTA_OK.
The lines returned by mtaDequeueLineNext() might not be NULL terminated because the returned line pointer might reference a line in a read-only, memory-mapped file.
Once the message has been processed and all the disposition of all recipients set, mtaDequeueMessageFinish() is called. This actually dequeues the message.
When all message processing is complete, process_message() exits. It is called again for each additional message to be processed.
HELO MAIL FROM:<firstname.lastname@example.org\> RCPT TO:<email@example.com\> DATA Received:from siroe.com by siroe.com (SunONE Messaging Server 6.0)id <01GP37SOPRW0A9KZFV@siroe.com\>; Fri, 21 Mar 2003 09:07:32 -0800(PST) Date: Fri, 21 Mar 2003 09:07:41 -0800 (PST) From: firstname.lastname@example.org To: email@example.com Subject: mtasdk_example1.c Message-id: <01GP37SOPRW2A9KZFV@siroe.com\> Content-type: TEXT/PLAIN; CHARSET=US-ASCII Content-transfer-encoding: 7BIT Hello world! . QUIT