[Dovecot] What best decision to make for flatfiles or SQL when I use Dovecot2 + Postfix together?
Hello,
I'm moving my mail server from Exchange to an opensource one.
After a bunch of reading, I decided on building a Dovecot2 + Postfix server in a VirtualUsers-only + Multiple-domains configuration.
Since my messages will be stored by Dovecot, and the documentation is really good, I figured that it's smartest to configure Dovecot, then make Postfix 'fit' to it, sharing the data files that way.
I read through lots of the Dovecot wiki for v2.
There are many ways for storing the database data. My goal is to only have data in one instances, used by both Postfix & Dovecot.
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
The data I think I need to share are:
users (user@domain.com) passwords user aliases (mapping user2@domain.com -> user1@domain.com) domains domain aliases (domain.com also receives email for domain2.com)
And I think all of this can be in passwd-db in Dovecot. But I also want to make sure that Postfix ONLY accepts email for users/domains that exist, so it has to read that data too.
Can I do this that way with the flatfiles? Or do I have to use the SQL approach?
TJ
On 27/09/11 17:51, terryjames9461@mm.st wrote:
Hello,
I'm moving my mail server from Exchange to an opensource one.
After a bunch of reading, I decided on building a Dovecot2 + Postfix server in a VirtualUsers-only + Multiple-domains configuration.
Since my messages will be stored by Dovecot, and the documentation is really good, I figured that it's smartest to configure Dovecot, then make Postfix 'fit' to it, sharing the data files that way.
I read through lots of the Dovecot wiki for v2.
There are many ways for storing the database data. My goal is to only have data in one instances, used by both Postfix & Dovecot.
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
The data I think I need to share are:
users (user@domain.com) passwords user aliases (mapping user2@domain.com -> user1@domain.com) domains domain aliases (domain.com also receives email for domain2.com)
And I think all of this can be in passwd-db in Dovecot. But I also want to make sure that Postfix ONLY accepts email for users/domains that exist, so it has to read that data too.
Can I do this that way with the flatfiles? Or do I have to use the SQL approach?
The problem with passwd(like) files is that they are almost never in the correct format to fit both daemons. The easiest way to use a database.
You could check out postfixadmin: it contains the database format you need, the documentation to hook postfix and dovecot into it, and a nice web gui for administrating the list of domains, aliases, mailboxes, passwords, etc etc.
-- Tom
Tom Hendrikx wrote:
On 27/09/11 17:51, terryjames9461@mm.st wrote:
Hello,
I'm moving my mail server from Exchange to an opensource one.
After a bunch of reading, I decided on building a Dovecot2 + Postfix server in a VirtualUsers-only + Multiple-domains configuration.
Since my messages will be stored by Dovecot, and the documentation is really good, I figured that it's smartest to configure Dovecot, then make Postfix 'fit' to it, sharing the data files that way.
I read through lots of the Dovecot wiki for v2.
There are many ways for storing the database data. My goal is to only have data in one instances, used by both Postfix& Dovecot.
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
The data I think I need to share are:
users (user@domain.com) passwords user aliases (mapping user2@domain.com -> user1@domain.com) domains domain aliases (domain.com also receives email for domain2.com)
And I think all of this can be in passwd-db in Dovecot. But I also want to make sure that Postfix ONLY accepts email for users/domains that exist, so it has to read that data too.
Can I do this that way with the flatfiles? Or do I have to use the SQL approach?
The problem with passwd(like) files is that they are almost never in the correct format to fit both daemons. The easiest way to use a database.
You could check out postfixadmin: it contains the database format you need, the documentation to hook postfix and dovecot into it, and a nice web gui for administrating the list of domains, aliases, mailboxes, passwords, etc etc. +1 one on PostfixAdmin. Wouldn't want to live without it. The main advantage of using a DB is that all information is stored in 1 location and available in the right format through SQL-queries. My 1st config used flat-files and the biggest issue was keeping the different files in sync (i.e. when creating/deleting users making sure to update all the necessary files).
My main concern was losing mails if the DB is unavailable but this isn't a problem; if the DB is unavailable Postfix will return a temporarily unavailable and the MTA should retry.
Rgds, N.
On Wed, September 28, 2011 6:47 am, Nick Rosier wrote:
My main concern was losing mails if the DB is unavailable but this isn't a problem; if the DB is unavailable Postfix will return a temporarily unavailable and the MTA should retry.
yes, that was also my biggest concern when I 1st looked at the issue, after several years of usage, it still remain my biggest concern
luckily, it's just a concern, never caused a problem, and, mail will queue up if there are issues
For my personal email, I have a habit of having the sql server down
for one reason or another. I just dump the sql tables to flatfiles on
the email server, and a script runs every 15min and checks for updates
if any exist. Works well.
Another method would be to just keep it sql, but dump the mysql tables
into sqlite tables that postfix/dovecot use.
Quoting Voytek voytek@sbt.net.au:
On Wed, September 28, 2011 6:47 am, Nick Rosier wrote:
My main concern was losing mails if the DB is unavailable but this isn't a problem; if the DB is unavailable Postfix will return a temporarily unavailable and the MTA should retry.
yes, that was also my biggest concern when I 1st looked at the issue, after several years of usage, it still remain my biggest concern
luckily, it's just a concern, never caused a problem, and, mail will queue up if there are issues
Hello Nick,
On Tuesday, September 27, 2011 9:47 PM, "Nick Rosier" nick+dovecot@bunbun.be wrote:
+1 one on PostfixAdmin. Wouldn't want to live without it. The main advantage of using a DB is that all information is stored in 1 location and available in the right format through SQL-queries. My 1st config used flat-files and the biggest issue was keeping the different files in sync (i.e. when creating/deleting users making sure to update all the necessary files).
Did you try that system with flatfiles in Dovecot v2 or v1? I think that this instructed possibility, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix, is only for v2?
Its that sync of the different files that I hope to avoid. If I can with flatfiles, all the better. If not then maybe I will have to use SQL. And then the Postfix Admin looks interesting.
TJ
Hello Nick,
On Tuesday, September 27, 2011 9:47 PM, "Nick Rosier" nick+dovecot@bunbun.be wrote:
+1 one on PostfixAdmin. Wouldn't want to live without it. The main advantage of using a DB is that all information is stored in 1 location and available in the right format through SQL-queries. My 1st config used flat-files and the biggest issue was keeping the different files in sync (i.e. when creating/deleting users making sure to update all the necessary files).
Did you try that system with flatfiles in Dovecot v2 or v1? I think that this instructed possibility, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix, is only for v2? This was back with v1. It was working with a little script I wrote. A problem was delegating management of all the domains. My servers hosts a number of domains which are owned by different people (family+friends). With PostfixAdmin you can define which user administers which domains (another perk).
Its that sync of the different files that I hope to avoid. If I can with flatfiles, all the better. If not then maybe I will have to use SQL. And then the Postfix Admin looks interesting. An additional advantage I found with PostfixAdmin is the possibility to run post-creation/editing/deleting scripts on mailboxes and domains. I'm using Amavisd-new and have the post-creation script create users in the Amavis-DB with e.g. the default policies for a user and populating some
terryjames9461@mm.st wrote: tables used by other tools (quarReminder etc...).
Rgds, N.
PS: my mailserver only hosts a couple of domains and less than 100 mailboxes. I could have done this with flat-files but the possibility to delegate mailbox creation/deletion to the domain owners was worth the "trouble" using a DB which I was using anyway for other services.
Hello Tom,
On Tuesday, September 27, 2011 7:29 PM, "Tom Hendrikx" tom@whyscream.net wrote:
The problem with passwd(like) files is that they are almost never in the correct format to fit both daemons. The easiest way to use a database.
I don't yet see using a database easier than flatfiles. I understand that the one-instance data is done well in a database.
But also I found this page at the Dovecot wiki, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix. I keep rereading it and I think that it tells me that I can do this with flatfiles only.
I think its this section, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix#Master_Configurat..., that tells how to share data with Postfix. Except there's also LMTP which I haven't figured out how to do it yet.
For only 3 domains and 30 users its silly to have to run a mysql database. But who knows yet if I an reading this right, and if sharing flatfiles are possible? Its confusing to read and understand.
TJ
Well, the info dovecot needs, it mailbox name/location, username,
password, and quota, misc info.
postfix will need email address to mailbox name mapping info.
That is the very basic things you need.
Using dovecot lda/lmtp you remove all postfix needs to know mailbox
name to directory mapping, that would be duplicated.
Quoting terryjames9461@mm.st:
Hello Tom,
On Tuesday, September 27, 2011 7:29 PM, "Tom Hendrikx" tom@whyscream.net wrote:
The problem with passwd(like) files is that they are almost never in the correct format to fit both daemons. The easiest way to use a database.
I don't yet see using a database easier than flatfiles. I understand that the one-instance data is done well in a database.
But also I found this page at the Dovecot wiki, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix. I keep rereading it and I think that it tells me that I can do this with flatfiles only.
I think its this section, http://wiki2.dovecot.org/HowTo/VirtualUserFlatFilesPostfix#Master_Configurat..., that tells how to share data with Postfix. Except there's also LMTP which I haven't figured out how to do it yet.
For only 3 domains and 30 users its silly to have to run a mysql database. But who knows yet if I an reading this right, and if sharing flatfiles are possible? Its confusing to read and understand.
TJ
Hello Patrick,
On Tuesday, September 27, 2011 6:06 PM, "Patrick Domack" patrickdk@patrickdk.com wrote:
Using dovecot lda/lmtp you remove all postfix needs to know mailbox
name to directory mapping, that would be duplicated.
With using the Dovecot lmtp option, where does Postfix know to refuse email for a non-existing user or domain? That also has to be shared?
I am trying to draw a picture in my head of all the data pieces. Are you saying that when using lmtp the data for Postfix and the data for Dovecot/LMTP do not overlap anymore? Each can have its own flatfiles?
TJ
Depends on how you think about it.
If you forget about email addresses. Dovecot works on mailbox's, and
it maps a mailbox to a path, username, and password.
In postfix, it only cares about email addresses (if you use dovecot
for delivery, if not then postfix also has to care about the mailbox
location). In this case you just tell postfix the email addresses that
are valid, and what mailbox they go to.
So normally most users would just have a 1 to 1 mapping in postfix,
email -> email, as their email address will be the same as their
mailbox. But then you might have extra, like, sales@x -> user@x
All depends on how flexable or simple you want it later. You could
just manage two flatfiles. Or you could have it create the 1 to 1
mapping automatically with a script, and just do the extra mappings
seperate. Or do the whole thing in sql, and use like postfixadmin to
manage it all. Or even use postfixadmin, and have a script pull the
results into flatfiles that it uses.
It all depends on how much time and energy you want to spend in
setting it up, vs the flexibility you in vision you need later.
I do it 3 different ways, on different systems, one is just sql fully,
nothing interesting. My personal email is sql, but dumped to local
flatfiles. And another system I pull the info from windows AD.
Quoting terryjames9461@mm.st:
Hello Patrick,
On Tuesday, September 27, 2011 6:06 PM, "Patrick Domack" patrickdk@patrickdk.com wrote:
Using dovecot lda/lmtp you remove all postfix needs to know mailbox name to directory mapping, that would be duplicated.
With using the Dovecot lmtp option, where does Postfix know to refuse email for a non-existing user or domain? That also has to be shared?
I am trying to draw a picture in my head of all the data pieces. Are you saying that when using lmtp the data for Postfix and the data for Dovecot/LMTP do not overlap anymore? Each can have its own flatfiles?
TJ
Hello Patrick,
On Tuesday, September 27, 2011 9:41 PM, "Patrick Domack" patrickdk@patrickdk.com wrote:
It all depends on how much time and energy you want to spend in
setting it up, vs the flexibility you in vision you need later.
This is the intersection of the decision. I still am no sure if that simple flatfile dream of one-instance data can be done. I think I am going to have to try it a number of times becuase I dont see a certain answer, yes or no.
Can you may be explain more what you do with your case that you dump SQL to flatfile? I don't see why that would ever be a benefit and am interested in understanding that.
I think I am worried about using SQL a bit because it is not something that I think I can edit so quickly as I do text files. And also like you others, losing data when things are corrupted.
TJ
-----Original Message----- From: dovecot-bounces@dovecot.org [mailto:dovecot- bounces@dovecot.org] On Behalf Of terryjames9461@mm.st Hello Patrick,
On Tuesday, September 27, 2011 9:41 PM, "Patrick Domack" patrickdk@patrickdk.com wrote:
It all depends on how much time and energy you want to spend in setting it up, vs the flexibility you in vision you need later.
This is the intersection of the decision. I still am no sure if that simple flatfile dream of one-instance data can be done. I think I am going to have to try it a number of times becuase I dont see a certain answer, yes or no.
Can you may be explain more what you do with your case that you dump SQL to flatfile? I don't see why that would ever be a benefit and am interested in understanding that.
I think I am worried about using SQL a bit because it is not something that I think I can edit so quickly as I do text files. And also like you others, losing data when things are corrupted.
I have reasonable evidence that I'm by no means a sys-admin or even a linux Guru. But for the past 5 years, I've managed a system like you're trying to build - Postfix/Amavis/SpamAssassin/Dovecot (until recently I was running Courier for the MDA) with an SQL backend. It's never let me down, gives me a web interface (with PHPMyAdmin) to make changes, has 7 domains and about 300 user accounts.
Once the set-up is done, you can save a file with a few queries or even build a php page to make common changes (adding domains/users, etc). Backup is easy. For the record, I've never used Postfixadmin - although I hear great things about it. Like the others, I'd recommend going the SQL route - it's easier to maintain and upgrade and it scales. If you don't need it to scale you've lost nothing because it uses virtually no resources, and if you do, you have it.
Simon
On Tue, Sep 27, 2011 at 03:14:12PM -0700, terryjames9461@mm.st wrote:
With using the Dovecot lmtp option, where does Postfix know to refuse email for a non-existing user or domain? That also has to be shared?
Sticking to the Flatfile recipe on the Wiki, Postfix would query the Auth Backend of Dovecot. The actual user records would sit on the Dovecot side, where Postfix would only worry about valid domains etc.
Fancy stuff like Aliasing would be better done on the Postfix side in this scenario although it would also be possible to have bogus User records in Dovecot to address that.
Thomas
On 28.09.2011, at 00:14, terryjames9461@mm.st wrote:
Hello Patrick,
On Tuesday, September 27, 2011 6:06 PM, "Patrick Domack" patrickdk@patrickdk.com wrote:
Using dovecot lda/lmtp you remove all postfix needs to know mailbox
name to directory mapping, that would be duplicated.With using the Dovecot lmtp option, where does Postfix know to refuse email for a non-existing user or domain? That also has to be shared?
I wondered that as well, and unfortunately the Howto doesn't explain the concept it builds upon. But I found it: it uses LMTP and recipient verification (see reject_unverified_recipient in smtpd_recipient_restictions).
See http://www.postfix.org/ADDRESS_VERIFICATION_README.html for details.
Rainer
Thanks to all for the instructions. I am working on the flatfile approach and making good progress.
I also set up some test MySQL options and they work too.
So I have the future plans already in my hand!
TJ
On Wed, September 28, 2011 2:51 am, terryjames9461@mm.st wrote:
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
personally, I'd suggest SQL, that's what I use, used it with CourierIMAP/Postfix, now, with Dovecot/Postfix, it works well, I also use Postfix.admin, for, well, admin
Voytek
On Tue, Sep 27, 2011 at 08:51:18AM -0700, terryjames9461@mm.st wrote:
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
Best approach is probably to store this in an ldap-directory. Then you can easily have multi-master replication, and avoid any single point of failure for your database. Both postfix and dovecot will be able to lookup the data using ldap.
-jf
On Wed, 28 Sep 2011 08:44:24 +0200 Jan-Frode Myklebust articulated:
On Tue, Sep 27, 2011 at 08:51:18AM -0700, terryjames9461@mm.st wrote:
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
Best approach is probably to store this in an ldap-directory. Then you can easily have multi-master replication, and avoid any single point of failure for your database. Both postfix and dovecot will be able to lookup the data using ldap.
While "ldap" may be fine for some users; personally, I have had nothing but catastrophic results when attempting to use it. I am fully aware that the main problem is that I am not truly "ldap" proficient. For the end user who needs an easy to maintain database I would unequivocally recommend MySQL. It has the added bonus of not requiring that Postfix (and I am not sure about Dovecot) be restarted if the database is changed. In Postfix, this also eliminates the requirement that "postmap" be run on the edited files prior to restarting Postfix.
Just my unsolicited 2¢.
-- Jerry ✌ Dovecot.user@seibercom.net
Disclaimer: off-list followups get on-list replies or get ignored. Please do not ignore the Reply-To header.
Jerry wrote:
On Wed, 28 Sep 2011 08:44:24 +0200 Jan-Frode Myklebust articulated:
On Tue, Sep 27, 2011 at 08:51:18AM -0700, terryjames9461@mm.st wrote:
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
Best approach is probably to store this in an ldap-directory. Then you can easily have multi-master replication, and avoid any single point of failure for your database. Both postfix and dovecot will be able to lookup the data using ldap.
While "ldap" may be fine for some users; personally, I have had nothing but catastrophic results when attempting to use it. I am fully aware that the main problem is that I am not truly "ldap" proficient. For the end user who needs an easy to maintain database I would unequivocally recommend MySQL.
+1 on the mysql.
/Per Jessen, Zürich
Am 27.09.2011 17:51, schrieb terryjames9461@mm.st:
Hello,
I'm moving my mail server from Exchange to an opensource one.
After a bunch of reading, I decided on building a Dovecot2 + Postfix server in a VirtualUsers-only + Multiple-domains configuration.
Since my messages will be stored by Dovecot, and the documentation is really good, I figured that it's smartest to configure Dovecot, then make Postfix 'fit' to it, sharing the data files that way.
I read through lots of the Dovecot wiki for v2.
There are many ways for storing the database data. My goal is to only have data in one instances, used by both Postfix & Dovecot.
I'm a little confused about: to do that sharing-in-one-place, do I have to use SQL or can I use the flatfiles like passwd-db? I think for sure someone already decided the best approach for this, and maybe I'm not understanding the logic to it.
The data I think I need to share are:
users (user@domain.com) passwords user aliases (mapping user2@domain.com -> user1@domain.com) domains domain aliases (domain.com also receives email for domain2.com)
And I think all of this can be in passwd-db in Dovecot. But I also want to make sure that Postfix ONLY accepts email for users/domains that exist, so it has to read that data too.
Can I do this that way with the flatfiles? Or do I have to use the SQL approach?
TJ
i do it all with postfixadmin and mysql, in my eyes you could use plain flat files , if your the only on who admins i.e over ssh etc
but if you want a customer friendly mailserver, with parted superadmin/domainadmin/user administration over some i.e. http gui you should better use sql and/or ldap stuff
-- Best Regards
MfG Robert Schetterer
Germany/Munich/Bavaria
participants (12)
-
Jan-Frode Myklebust
-
Jerry
-
Nick Rosier
-
Patrick Domack
-
Per Jessen
-
Rainer Frey
-
Robert Schetterer
-
Simon Brereton
-
terryjames9461@mm.st
-
Thomas Leuxner
-
Tom Hendrikx
-
Voytek