How to reinstall postfix

SYSTEM INFORMATION
OS type and version ROCKY LINUX 9.5
Webmin version 2.202

How to reinstall postfix with the original webmin configuration?
I don’t think it will be necessary to delete the entire webmin/virtualmin.
If I delete the postfix server, how do I get the parameters to rebuild it?

Is there such a thing? I thought Webmin was only a system management tool?

Well, the install script does this at startup. I think the real question is what problem do you have that you think reinstalling Postfix will solve? If you have etckeeper installed you might be able to roll back some recent changes.

Is it even installed by Webmin?
If you have installed it then I guess you should already know the answer.

I thought it came with and is managed by Virtualmin (when requesting mail) and would then guess that deliberately removing it (why would anyone?) would lead to a whole lot of hurt.

I did some experiments for email security and now I’m not able to send or receive emails.

Therefore just remove your experiments assuming your mail system worked before you messed with it. I hope you backed up the configuration files before you experimented if so it will be a case of just restoring these.

Thank you for your interaction but existing backups are recent and this has been going on for some time.
I thought about getting the right SMTP screens, or even getting main.cf and master.cf.

Why do folk only understand the need for a disaster recovery plan after experiencing a disaster?

So you didn’t backup main & master.cf before messing with them ? But if you have etckeeper installed you can go back through the commits to find one that did work

1 Like

Are you really talking about just Webmin? (And not Virtualmin?)

There is no default configuration with Webmin. Webmin manages whatever configuration file it finds in the configured location.

Please read all of what I’m about to say before doing anything, because I’m about to say some things that if you go off half-cocked, you could break things much more dramatically than currently.

If it’s a Virtualmin configuration, it is modified slightly during installation of Virtualmin. The changes Virtualmin makes can be found here: Virtualmin-Config/lib/Virtualmin/Config/Plugin/Postfix.pm at master · virtualmin/Virtualmin-Config · GitHub

Or, from a freshly installed Postfix package you could run virtualmin config-system -i Postfix

But, you should not freshly install Postfix, because that would blow away your virtual maps and any other maps that have been setup since you installed. On a production system, your first instinct should never be “let’s reinstall this”, because on a production system, you probably have a bunch of custom configuration that will not be reproduced by performing the Virtualmin initial configuration.

It depends on what you changed and where as to what file(s) need “fixing”, but you certainly don’t want to blow away virtual and any other maps that are in use (which maps are used depends on your configuration, if you’re using sender dependent relays or something else, you may have several things that are not going to be found in a fresh install+Virtualmin configuration stage).

So, if you must reinstall, the right way to do it on an RPM-based OS (this will be different on a deb-based OS) is:

  1. Find out what’s been modified from the original Postfix installation. rpm -V postfix
  2. Move all the modified files out of the way (it will be at least four files, maybe more, depending on your own customizations).
  3. Use dnf reinstall postfix to put it back in place. Do not uninstall it!
  4. Use virtualmin config-system -i Postfix
  5. Use virtualmin config-system -i SASL

Copy back any map files (this is at least virtual, but may be others). Compare main.cf and master.cf to see if there’s any other configuration you want to keep from the old. Obviously don’t copy whatever was broken before.

“Reinstall” should be a word that strikes fear into your heart on a production system, and is a last resort if you can’t selectively restore a backup from before the problem started. Merely getting a default Virtualmin configuration probably will cause new problems.

I followed your recommendations to reinstall postfix.

An example of what I see in journalctl -n 100 -u postfix.service

postfix/smtpd[37837]: warning: SASL: Connect to smtpd failed: No such file or directory

postfix/smtpd[37837]: fatal: no SASL authentication mechanisms

postfix/master[5784]: warning: process /usr/libexec/postfix/smtpd pid 37837 exit status 1

postfix/master[5784]: warning: /usr/libexec/postfix/smtpd: bad command startup – throttling

Looks like saslauthd is disabled or stopped.

Start/enable it:

systemctl start saslauthd
systemctl enable saslauthd

Probably ought to check the logs for that to make sure it doesn’t have problems, too. Then restart postfix again and see what happens.

The problem still remains. I checked my past notes and could see that at a certain point when postfix wasn’t working, I uninstalled it and reinstalled it again. What I shouldn’t have done if I had the knowledge shared by you in this interaction.
I thank you very much, but I believe that I should set up the individual backups of each website to make a new installation of Virtualmin so that everything is correctly configured. As I have few websites on this server, it will be fast.
Another option could be to reinstall the Cyrus SASL server, which would fix the problem.

I have already reinstalled the websites on a new Virtualmin installation. I appreciate everything.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.