Mail for domain error if postfix installed before Virtualmin and maps in MySQL

Ubuntu:
20.04LTS:
Hi,
I am trying to configure mail for domain example.com thru Virtualmin Pro.
I have working (running) Postfix mail server already manually configured to accept and send mail for other domains I host on my server;

Postfix Mail server in Webmin for ‘Domain mapping lookup tables’ is set to:
mysql:/etc/postfix/mysql_virtual_alias_maps.cf

with content:
hosts = 127.0.0.1
user = usernamexxx
password = passwordxxx
dbname = postfixadmin
query = SELECT goto FROM alias WHERE address='%s' AND active = 1
table = alias
select_field = domain
where_field = active

but when I try to enable Mail for domain example.com I got error:
Adding to email domains list …
… Mail for domain failed! : SQL insert failed : Incorrect integer value: ‘example.com’ for column ‘active’ at row 1

I don’t know how to resolve this problem and I would much appreciate some help and suggestions.

You already had Postfix installed on your system before you installed Virtualmin on it? You are supposed to install Virtualmin on a server which has nothing but the OS installed.

Yes, I have Postfix and also Apache server installed before Virtualmin.
For now everything looks OK only the Postfix problem I described.

Well, most of us here have installed Virtualmin as per the official documentation. You have elected to choose a different path and are in uncharted waters.

I wish you the best of luck.

Thank you @calport for your good wishes.

I am still hoping for an helping answer in a manner of what to check, what to alter, how to use mysql maping

This sounds like a bad idea. Are you sure you really want your postfix maps in MySQL? Why?

Hello @Joe
I have installed Postfix , MySQL server and Apache long before Virtualmin.
Everything is working fine. I added a new domain - website is working, mysql is working, I can read Mail for that new domain in Usermin… I can edit this new domain just fine except I can not enable Mail for domain.
The file: ‘/etc/postfix/mysql_virtual_alias_maps.cf’ mentioned above in my original post is the file Postfix is using to determine virtual mail domains.
I have setup Postfix following this tutorial: Postfix
For now I am managing virtual mail domains thru postfixadmin
but I would like to be able to enable Mail for domain in Virtualmin.

Yeah, that’s a mistake. Wildly complicated setup.

Anyway, you can’t manage mail with Virtualmin with this configuration. You’ll need to disable mail in Features and Plugins and keep managing your mailboxes as you have been.

Thank you @Joe for your replay.
What do you think if I install Virtualmin to my other Ubuntu machine which has no Postfix, and no LAMP installed and give it a try there?

That is a good idea @Markoamb. Just make sure:

  1. the server has a fresh install of Ubuntu
  2. Ubuntu is for a version that is included in the Class A supported - Virtualmin OS Support | Virtualmin
  3. You use the automated install procedure for Virtualmin - Automated Virtualmin Installation | Virtualmin
1 Like

Yeah @calport , I will try it…
You know how it goes…, you build your server over the years and there is a lot of working hours put into it and then you feel a bit disappointed when something like this mail mapping doesn’t work…

Thank you for your support though

Virtualmin doesn’t support maps in MySQL. I’m not trying to be discouraging, it’s just not something that can be done without a considerable amount of new code.

And, it is almost always worse from a technical perspective to put maps into MySQL. It is slower than regular hash maps (by an order of magnitude or so, probably, though map lookups are such a tiny part of the mail delivery process that it doesn’t matter), it is more resource-intensive (both memory and CPU, though less so if you already have MySQL in use on the system for websites or other stuff), it introduces a new potential point of failure, and adds a new potential vector of attack in terms of security. And, it is more complicated to setup and maintain. All for no benefit in 99% of deployments at the scale people use Virtualmin for.

I’m not saying no one should ever put maps in MySQL, but I am saying that almost no one should put maps in MySQL. If you don’t have an extremely good reason to do it, you should not do it. And, managing maps in MySQL is not something we’d have any interest in adding to Virtualmin (because I don’t think most Virtualmin users should put their maps in MySQL, and we’re trying to guide people into making reasonable choices to build servers that can be maintained by people of varying technical ability over many years without a huge investment of time). So, if someone wanted to use Virtualmin with maps in MySQL that someone would need to build it.

Hope this clarifies why we’re not trying to help you use your existing mail configuration. We just can’t. It isn’t a capability Virtualmin has, and because it is unnecessarily complex, it’s not a capability Virtualmin is likely to ever have.

Yes, I know exactly how you feel. Standardization is the answer if one wants to put in hours of work and then not see it go down the drain. Fortunately Virtualmin offers a degree of standardization in how a system is configured when the Virtualmin Automated Install process is used and there is a community of users and enthusiasts who support this standardized install of Virtualmin, so the working hours that we all, as a community, put into a common standardized system produces insight and experience that we can share with each other in order to help each other create and maintain a hosting environment that can work reliably for many years.

Additionally, Virtualmin supports multiple OSs and is not intrusive like many of the other web hosting control panels are, which I feel is a USP worth noting.

Let us know if you need assistance with your Virtualmin install on the other Ubuntu system.

I understand @Joe what are you saying.

But I am already near a solution.
I will post it later if everything goes well. For now just a hint:
I am already able to enable Mail for that new domain…
:wink: :wink:

1 Like

@calport
I am grateful for your effort to helping me out.
I will see if I can manage to configure current Virtualmin to work as it should.
As I already replayed to @Joe I am already able to enable Mail for that new domain.
I need to check if everything is working and then I will post an solution to my question.

Your title says this:
Mail for domain error if postfix installed before Virtualmin and maps in MySQL

The very first sentence in the instructions for your OS in advance of installing Virtualmin says this:
Do not pre-install or pre-configure any additional packages on your OS.

It never ceases to amaze me how many people post about problems that they themselves create for absolutely no reason on earth.

I should own up to this: I edited the topic to reflect the discussion as it developed in order to make it meaningful to humans as well as the bots.

The original topic was just “Mail for domain error” and the OP was probably not aware, when he installed Virtualmin, of many things that he now is.

2 Likes

Lesson learned - hard way.
And dear @Gomez_Adams thank you for drooping by.
:smiling_face_with_three_hearts:

I’m not the one that can’t follow very simple directions. You are.

Keep it friendly, y’all.

2 Likes