Postfix virtual maps

Hi All

I have a fresh net install of Debian Etch and I keep getting this Postfix error when I do the Configuration checking with the vitualmin install.

A problem was found with your Postfix virtual maps : The map source mysql:/etc/postfix/mysql-virtual-alias-maps.cf cannot be used : The MySQL configuration parameter table was not found. Webmin needs this to figure out which table and fields to query.
I followed this tutorial
http://workaround.org/articles/ispmail-etch/
for setting up the mail server and it seems to work, but I have this Virtualmin error. Here is the mysql-virtual-alias-maps.cf [code:1]user = mailuser password = ******** hosts = 127.0.0.1 dbname = mailserver query = SELECT destination FROM view_aliases WHERE email='%s'[/code:1] and here is the postfix main.cf [code:1] smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no

append_dot_mydomain = no

smtpd_tls_cert_file = /etc/ssl/certs/postfix.pem
smtpd_tls_key_file = /etc/ssl/private/postfix.pem
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

myhostname = BuildFITs1.buildfit.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = BuildFITs1.buildfit.com, localhost, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.1 10.0.0.0/24
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf, mysql:/etc/postfix/mysql-email2email.cf
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_tls_auth_only = yes
content_filter = smtp-amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings[/code:1]
I have tried for 2 days now to resolve this issue with no luck, any help would be very much appreciated tku

Are you sure you want to use MySQL virtual maps? Are you really sure? It’s almost certainly a bad idea.

I’d strongly recommend a standard hash style virtual map, unless you really, really, really know what you’re doing. (A local hash map is dramatically faster, more efficient, and simpler to manage…and, of course, setting up local maps is practically impossible to screw up.)

Thankyou so much for your fast reply jow

Joe wrote:

Are you sure you want to use MySQL virtual maps? Are you really sure? It's almost certainly a bad idea.

I’d strongly recommend a standard hash style virtual map, unless you really, really, really know what you’re doing. (A local hash map is dramatically faster, more efficient, and simpler to manage…and, of course, setting up local maps is practically impossible to screw up.)

The mysql alias maps came from the ISP style mail tutorial I followed in my above query, if I went for hash style ( not really knowing difference except one uses a database ) does this mean I would delete the mailserver db i setup in this tutorial? and if so

What are the steps in converting what I have done to hash style?

Also, in what situation would one use mysql mapping over hash mapping?

Thank you once again

sorry for the typo in your name joe

What are the steps in converting what I have done to hash style?

Undo everything you did in the tutorial, and instead add the following single line to main.cf:

virtual_alias_maps = hash:/etc/postfix/virtual

does this mean I would delete the mailserver db i setup in this tutorial?

Yes, I would recommend that. Using MySQL for virtual tables is thoroughly dumb. :wink:

Also, in what situation would one use mysql mapping over hash mapping?

Never. (Slight exaggeration, but because it’s such a bad idea that so many people keep taking as a good idea that I don’t want to mince words or leave any doubt.)

If you have thousands of users (I’m not sure exactly at what point it becomes a win…maybe 20,000?) or they are spread across more than one system, you would then need to use a database. But, MySQL is never the database I would suggest for this…LDAP is far better suited for this type of storage.

(OK, so there is one exception to this rule: You have all of your users in MySQL already and they must be there because a bunch of other stuff requires them to be in MySQL. But, it’s far more likely that you’ll have a situation where LDAP is required.)

So, let me briefly clear up a few misconceptions about MySQL backed mail users:

They are not faster. They are dramatically slower. Not just a little slower…we’re talking about an order of magnitude slower for anything less than several thousand users (again, I’m not sure how many thousand…but it’s certainly in the tens of thousands.)

They are not more reliable. MySQL is trustworthy, and quite reliable. But, it’s another big complicated piece of machinery that has to be working…in addition to all of the Postfix machinery. All things being equal, one complex piece of machinery is about half as likely to fail as two complex pieces of machinery.

They are not easier to manage. They look identical in the Webmin UI, and the virtual map file is an easy to understand format. Databases aren’t hard to manage…but they aren’t as easy to use as a text file.

And, finally, they’re not easier to configure, as you’ve found out. :wink:

The funny thing about this whole problem is that people think that because MySQL is awesome for some tasks (and it is!), it is awesome for all tasks. But, this is not one of those situations where introducing a whole new pile of complexity is a good idea. Simpler is better.

I’m not picking on you, I’m picking on the folks who’ve misled you. There are about a dozen tutorials on the web for setting up Postfix for use with MySQL, and it’s really easy to come away thinking it’s the right way (or even only way) to setup Postfix for this kind of hosting. I don’t want to criticize folks for posting helpful information on the web, but this is a pet peeve of mine…we get a lot of folks who’ve broken their postfix in this way, and they never needed to go to all this trouble. One line in the configuration file would have done everything they needed to do, and they wouldn’t have wasted any time or had to go through all this confusion.

Hi Joe

Thank you very much for that heads up, I will make the changes tomorrow and let you know how it goes.

cheers :slight_smile:

All sweet now its using hash instead of mysql, tku for your assistance

Sorry to resurrect this thread, but I had the same issue and some people might be interested in a fix while still using MySQL.

I agree with what Joe said above. I might have been guilty in assuming that using MySQL as part of my mail server was the best way of doing this too. I will have to take a harder look at whether or not I want to continue to use MySQL.

With that said, if you did happen to follow the tutorial at http://workaround.org like Dragon and myself did (It’s a good tutorial!), then you can fix the error by editing the following two files.

Edit /etc/postfix/mysql-virtual-alias-maps.cf and add the following to the bottom:

table = virtual_aliases
select_field = destination
where_field = source




You will also want to edit /etc/postfix/mysql-email2email.cf and add the following to the bottom:

table = virtual_users
select_field = email
where_field = email




Hope that helps someone in the future!