Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Postfix and MySQL, why?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mariourk
l33t
l33t


Joined: 11 Jul 2003
Posts: 807
Location: Urk, Netherlands

PostPosted: Fri Apr 17, 2009 10:46 am    Post subject: Postfix and MySQL, why? Reply with quote

I know it is possible to combine Postfix with a MySQL database. Only I don't see why this is so much better that the standard maildir approach.

Our mailserver will be replaced by a new one in the near future. So this would be a good moment to see if anything can be improved. Right now we've always worked with mailboxes and that always worked fine. However, if there is a good reason to use MySQL instead, I would really like to know.

Hopefully someone can fill me in here :D
_________________
If there is one thing to learn from history, it's that we usualy don't learn anything from it, at all.
Back to top
View user's profile Send private message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Fri Apr 17, 2009 1:35 pm    Post subject: Reply with quote

all mail and groupware systems that are designed for large environments use databases as storage backend, m$ exchange, lotus domino, ...
this has several (possible) advantages
  • speed (accessing a database is cheaper than performing open/close operations on ordinary files)
  • easy replication (databases are designed to mirror the content redundant in different places, at least with one read only copy, which results in rebustness
  • standardized data access path (SQL), in case you want to access the mails with custom applications for whatever reason (e.g. archiving)
  • the known database advantages (e.g. ACID (well, that does not apply to all mysql storage backends))
you may or may not profit from using a database, but generally it is not a bad idea.
if you have the choice, favor postgresql over mysql.
Back to top
View user's profile Send private message
mariourk
l33t
l33t


Joined: 11 Jul 2003
Posts: 807
Location: Urk, Netherlands

PostPosted: Sat Apr 18, 2009 1:08 pm    Post subject: Reply with quote

And are all the emails stored in the database as well? Or are the emails still stored in the maildir and is the database merely containing links (or an index, if you wil) to those files?
_________________
If there is one thing to learn from history, it's that we usualy don't learn anything from it, at all.
Back to top
View user's profile Send private message
overkll
Veteran
Veteran


Joined: 21 Sep 2004
Posts: 1249
Location: Austin, Texas

PostPosted: Sat Apr 18, 2009 4:53 pm    Post subject: Reply with quote

Most users who implement postfix with MySQL use MySQL to store user/authentication information ie username/password/domain information. This way users aren't actually system users (user/password not in /etc/passwd) and cannot access the mail server via shell/login/ssh/telnet etc. The MySQL database IS NOT used to store email messages. Where and how messages are stored depends on you. One can use mbox files, maildir, or maildir like storage systems (like cyrus-imapd). Commonly used MDAs (mail delivery agent) are dovecot, courier-imap and cyrus-imapd.

MySQL can also be used for postfix access/lookup lists - mydestination, local_recipient_maps, aliases_maps, virtual_alias_maps, virtual_mailbox_domains, etc.

It's all very well documented at www.postfix.org
Back to top
View user's profile Send private message
mariourk
l33t
l33t


Joined: 11 Jul 2003
Posts: 807
Location: Urk, Netherlands

PostPosted: Sat Apr 18, 2009 5:37 pm    Post subject: Reply with quote

But if emails are not stored in the database and users are not system users (because they are created in the database) where are the emails being stored? Right now the are stored in their home-folder. But when they are no longer system-users, there is no homedir. So, where does it go?

Perhaps someone knows some good documentation that explains how it basically works? All I can find are howto's that tell how to set things up. They often forget to explain why one would want to use it in the first place and how the principle works :wink:
_________________
If there is one thing to learn from history, it's that we usualy don't learn anything from it, at all.
Back to top
View user's profile Send private message
overkll
Veteran
Veteran


Joined: 21 Sep 2004
Posts: 1249
Location: Austin, Texas

PostPosted: Sat Apr 18, 2009 6:36 pm    Post subject: Reply with quote

It sounds like your coming from an environment where one app does everything - Exchange, Lotus Notes? Excuse me if I'm making the wrong assumption.

Using postfix is completely different. It's main purpose is as a SMTP server/MTA - Mail Tranport Agent - routing incoming messages to a mail store or Mail Delivery Agent, and routing outgoing messages to their final destination on the net. Basically it's just relaying messages.

Postfix can be configured to deliver inbound messages to a mbox or maildir format mail store, AND postfix can be configured to deliver to an MDA (cyrus, dovecot, uw-imap/pop, courier, etc). The MDA is used to take care of the mail store, and connect users via pop/imap to their message store (INBOX and/or folders).

For example, I prefer a postfix/cyrus-imapd setup. Users are virtual users and are stored in a MySQL database. Both Postfix and Cyrus use the database for authentication. Incoming messages are received by postfix, then handed off to cyrus (the MDA) via lmtp. Cyrus will then store the messages in /var/spool/imap/. When users access their mail via pop or imap, cyrus (not postfix) controls the process of the users accessing/downloading their mail.

Where the mail is actually stored depends on the MDA, whether users are virtual or real, and how one configures it.

http://en.wikipedia.org/wiki/Mail_server

is a good place to start. Check the "See also" links as well
Back to top
View user's profile Send private message
mariourk
l33t
l33t


Joined: 11 Jul 2003
Posts: 807
Location: Urk, Netherlands

PostPosted: Sun Apr 19, 2009 6:54 am    Post subject: Reply with quote

Right now I'm using Postfix/Courier to handle the mail, so I'm familiar with what you are saying.
I just never realized that Courier would handle the storage of the mail and not Postfix. Actually,
this makes a lot of sense.

Your explanation helped me a lot, thanks! :D
_________________
If there is one thing to learn from history, it's that we usualy don't learn anything from it, at all.
Back to top
View user's profile Send private message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Sun Apr 19, 2009 12:27 pm    Post subject: Reply with quote

of course you do not have to, but if you wish to store the emails in a database too, you can use net-mail/dbmail.
Back to top
View user's profile Send private message
overkll
Veteran
Veteran


Joined: 21 Sep 2004
Posts: 1249
Location: Austin, Texas

PostPosted: Sun Apr 19, 2009 3:29 pm    Post subject: Reply with quote

mariourk wrote:
Your explanation helped me a lot, thanks! :D

Alsjeblieft ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum