I’ve implemented “next day” delivery this week by taking messages submitted 
through Postfix, queuing the messages in a MySQL database, and sending them out 
for delivery through another Postfix instance/Dovecot LMTP proxy with final 
delivery using the destination mail servers LMTP service. Delivery is sent to a 
“next day” mail server which is sync’d to the recipient’s mail server using 
“doveadm sync -A tcp:next-day-mail:12345” on each mail server in the early 
morning.

This all appears to be working well. I do have a need to deliver these messages 
into specific mail folders in the recipient’s mailbox and I was planning on 
using global Sieve scripts running on the “next day” mail server to place the 
messages in the proper folder (not all messages are delivered to the INBOX 
folder).

I am using a PHP script to move the messages from Postfix to the MySQL database 
and then later sending them via SMTP to the internal Postfix instance for 
delivery to the “next day” mail server. I started investing how to code the 
Sieve scripts today and it occurred to me that I could greatly simplify message 
delivery by using IMAP to deliver the messages to the “next day” mail server. 
The PHP script would be able to deliver the exact message that should be stored 
to the proper folders setting the \Seen flags appropriately. 

My backend “next day” mail server already supports Master password login so I 
figure the PHP script should be able to login via IMAP to access the folders in 
the recipient mailboxes. Also, the PHP script could do other mailbox 
maintenance tasks when it connects to the user’s mailbox such as purge folders 
by age, message count, etc. The PHP script could also retrieve info about the 
current state of the user’s mailbox folders (like the date of the oldest unread 
message, how many messages have been read in the last week or so, etc) and 
store this data in the MySQL DB.

I’m looking for any advice on whether to scrap the current plan of deploying 
internal Postfix SMTP/Dovecot LMTP proxy/Dovecot LMTP/Sieve script for “next 
day” mail delivery and just write PHP script to access Dovecot IMAP (direct to 
the “next day” mail server or to the user’s mail server for “immediate” 
delivery).

This would allow me to drop using Dovecot LMTP at all. Postfix SMTP would only 
be configured to invoke a PHP script to deliver messages to the database (which 
is already implemented). Postfix would still use Dovecot IMAP authentication, 
but only Dovecot IMAP service would need to be “highly available”.

Any opinions? Should I dump LMTP?

Kevin

Reply via email to