{"id":2111,"date":"2022-08-30T15:22:08","date_gmt":"2022-08-30T15:22:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/02\/integrating-multiple-mailboxes-dovecot-exim-maildir-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:08","modified_gmt":"2022-08-30T15:22:08","slug":"integrating-multiple-mailboxes-dovecot-exim-maildir-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/integrating-multiple-mailboxes-dovecot-exim-maildir-collection-of-common-programming-errors\/","title":{"rendered":"Integrating multiple mailboxes (dovecot, Exim, maildir)-Collection of common programming errors"},"content":{"rendered":"<p>Following an outage, I&#8217;ve ended up with 2 mailboxes for each of my users, on separate machines. I&#8217;ve shut the interim machine down now, and put the mailboxes on the real server in <code>\/srv\/scratch\/$username\/Maildir\/...<\/code>, and need to integrate the messages from them, ideally preserving read\/seen state, into the users&#8217; canonical mailboxes, <code>\/srv\/mail\/$username\/Maildir\/...<\/code>. I have no preference for whether this is as a sub-folder, or in their main inbox, however I am confident none of the temporary mailboxes contain sub-folders themselves. (If they do, more fool the users, who were explicitly told not to do this on the temporary accounts!)<\/p>\n<p>Is there a good way to do this which minimises risk of loss of mail, and means their clients will automatically pick up the new folder\/messages (whichever it needs to be) when they reconnect? Alternatively, what do I need to do to tell Dovecot about the new messages after dumping them into the Maildirs?<\/p>\n<p>Both servers were built using Exim4 for delivery and Dovecot for IMAP.<\/p>\n<ol>\n<li>\n<p>I&#8217;d script moving the files into place using almost the Maildir delivery specification, which involves using the tmp\/ dir and then renaming into the new\/ dir, but for this you&#8217;d rename into the cur\/ or new\/ dir, depending upon where the original file was.<\/p>\n<p>Given that the filenames embed timestamps, you should have very few (zero) collisions, but paranoia is good. Write the file into tmp\/; if this was a cur\/ file, save away the state suffix outside the filename; whether moving to new\/ or cur\/ check both for existence of the same name in new\/ or the same prefix in cur\/; then rename as appropriate.<\/p>\n<p>Be careful not to lose the suffix on the cur\/-in-tmp\/ through a memory crash; a logfile journal of all actions taken will help you reconstruct if something goes wrong.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-02 12:05:59. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Following an outage, I&#8217;ve ended up with 2 mailboxes for each of my users, on separate machines. I&#8217;ve shut the interim machine down now, and put the mailboxes on the real server in \/srv\/scratch\/$username\/Maildir\/&#8230;, and need to integrate the messages from them, ideally preserving read\/seen state, into the users&#8217; canonical mailboxes, \/srv\/mail\/$username\/Maildir\/&#8230;. I have no [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2111","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2111"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2111\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}