[Dovecot] From Maildir back to smtp
Not sure how this can be done.
Right now I'm running a free backup MX record service. People point their high MX records to my servers and if they go down we store the email. When they come back up it's delivered.
What I want to do is have a premium service that would allow them to view through IMAP the stored email. In order to do that I would have to deliver the email locally to a dovecot server - to a single account perhaps - and they can view/forward/delete etc.
But - when their server comes back online I'd like to gather up all the delivered email stored in Maildir format and run it back into smtp for delivery.
Has anyone even done something like this? Or is there an easier way that I'm missing?
Thanks in advance
Il 23/02/2012 21:41, Marc Perkel ha scritto:
Not sure how this can be done.
Right now I'm running a free backup MX record service. People point their high MX records to my servers and if they go down we store the email. When they come back up it's delivered.
Hi, store how? In a queue with smtp server?
What I want to do is have a premium service that would allow them to view through IMAP the stored email. In order to do that I would have to deliver the email locally to a dovecot server - to a single account perhaps - and they can view/forward/delete etc.
But - when their server comes back online I'd like to gather up all the delivered email stored in Maildir format and run it back into smtp for delivery.
If you store the messages in a queue you can configure your smtp (your MX) server to send a copy of all message it receive also to another mailbox, see always_bcc in posfix.
On Thursday 23 February 2012 22:12:14 mailing@securitylabs.it wrote:
Il 23/02/2012 21:41, Marc Perkel ha scritto:
Not sure how this can be done.
Right now I'm running a free backup MX record service. People point their high MX records to my servers and if they go down we store the email. When they come back up it's delivered.
Hi, store how? In a queue with smtp server?
What I want to do is have a premium service that would allow them to view through IMAP the stored email. In order to do that I would have to deliver the email locally to a dovecot server - to a single account perhaps - and they can view/forward/delete etc.
But - when their server comes back online I'd like to gather up all the delivered email stored in Maildir format and run it back into smtp for delivery.
Sounds like a job for serialmail, a sister package to qmail: Use serialmail to forward mail from a mailbox (in Maildir format which you have) to the primary MX when it's back up. I've provided a mailbox/forwarding secondary MX service for several clients using this method (esp. 'maildirsmtp' program from serialmail with cron). More info/help on the qmail or serialmail mailing lists; URL for serialmail is,
http://cr.yp.to/serialmail.html
(it includes man pages within the package)
A couple of particular advantages of having secondary MX email in a mailbox as you suggest for forwarding:
Unlike mail in a queue, the messages don't expire, so if the primary MX takes forever to come back up that's fine (except for your disk storage)
Since the mail is in a mailbox you can access this with IMAP or POP3 as you suggest [until it's emptied when the primary MX returns]
I've not considered running serialmail in an non-qmail environment, but it would probably still work for the purpose you have in mind if you're using a different MTA.
If you store the messages in a queue you can configure your smtp (your MX) server to send a copy of all message it receive also to another mailbox, see always_bcc in posfix.
cheers,
Andrew.
On 23/02/2012 21:41, Marc Perkel wrote:
Not sure how this can be done.
Right now I'm running a free backup MX record service. People point their high MX records to my servers and if they go down we store the email. When they come back up it's delivered.
What I want to do is have a premium service that would allow them to view through IMAP the stored email. In order to do that I would have to deliver the email locally to a dovecot server - to a single account perhaps - and they can view/forward/delete etc.
But - when their server comes back online I'd like to gather up all the delivered email stored in Maildir format and run it back into smtp for delivery.
I'm thinking it would be possible to use dsync for this? Ideally you would have to have a way to maintain a duplicate of the AUTH database, so that users could use their current passwords for accessing it (this would obviously require the approval and cooperation of whoever you are providing this service to), but this way you could store each users mail individually and provide relatively painless access (since all each user would need to know is the backup host name and their username/password).
You'd have to configure a script on your end to:
determine a reliable way to differentiate between a temp-fail situation on the primary (in which case you just act as a normal backup MX), or an extended outage (15 minutes? 1 hour? I'd probably let the customer decide this one), which would determine when you start actually taking delivery of their mail to the 'standby' server
monitor for when the primary comes back online
wait xx interval to make sure the primary stays up (again, I'd let the customer decide this, but with a sane minimum that you define)
once the primary stays up for the required interval, dsync a one way 'dump' of the stored mails, being sure to test for success - and this process would obviously have to take into account the possibility of the primary going down again in the middle of the dsync
mv successfully restored mails on the backup mx to a temp location for xx 'safety' interval 'just in case'
delete the backed-up/stored mail that has been successfully dsync'd after the safety interval has elapsed
--
Best regards,
Charles
On 2/24/2012 4:18 AM, Charles Marcus wrote:
On 23/02/2012 21:41, Marc Perkel wrote:
Not sure how this can be done.
Right now I'm running a free backup MX record service. People point their high MX records to my servers and if they go down we store the email. When they come back up it's delivered.
What I want to do is have a premium service that would allow them to view through IMAP the stored email. In order to do that I would have to deliver the email locally to a dovecot server - to a single account perhaps - and they can view/forward/delete etc.
But - when their server comes back online I'd like to gather up all the delivered email stored in Maildir format and run it back into smtp for delivery.
I'm thinking it would be possible to use dsync for this? Ideally you would have to have a way to maintain a duplicate of the AUTH database, so that users could use their current passwords for accessing it (this would obviously require the approval and cooperation of whoever you are providing this service to), but this way you could store each users mail individually and provide relatively painless access (since all each user would need to know is the backup host name and their username/password).
You'd have to configure a script on your end to:
determine a reliable way to differentiate between a temp-fail situation on the primary (in which case you just act as a normal backup MX), or an extended outage (15 minutes? 1 hour? I'd probably let the customer decide this one), which would determine when you start actually taking delivery of their mail to the 'standby' server
monitor for when the primary comes back online
wait xx interval to make sure the primary stays up (again, I'd let the customer decide this, but with a sane minimum that you define)
once the primary stays up for the required interval, dsync a one way 'dump' of the stored mails, being sure to test for success - and this process would obviously have to take into account the possibility of the primary going down again in the middle of the dsync
mv successfully restored mails on the backup mx to a temp location for xx 'safety' interval 'just in case'
delete the backed-up/stored mail that has been successfully dsync'd after the safety interval has elapsed
I was wondering if I could just gather up the maildir files, reprocess them into batch SMTP format and run them back into Exim?
participants (4)
-
Andrew Richards
-
Charles Marcus
-
mailing@securitylabs.it
-
Marc Perkel