Have Webmin edit the .mc file instead of the .cf file in Sendmail

SYSTEM INFORMATION
OS type and version EL9
Webmin version 2.400

Can the Webmin Sendmail module be changed to edit the sendmail.mc file rather than the .cf file?

Directly changing the .cf makes it problematic to then check or edit settings in the .mc file. It also means that any edits to .mc causes previous Webmin changes to be lost. I cannot see the benefit of it working this way.

I have been trying to switch from sendmail to postfix but it just doesn’t allow things to work that I need.
Example is to check a whitelist.rbl, then only if that fails check the first blacklist RBL, if that fails check the next etc.
Best solution with postfix so far uses postscreen and that scatter bombs every RBL for each incoming IP, then adds the scores up to decide it the IP should be blocked or not.
Apart from a waste of resouces, it makes messy logs and spamhaus may get annoyed at all the extra requests.
That is just the first issue, and I have wasted many hours to no avail.

Please don’t try to convince me to use Postfix. :slight_smile:

But we’re already editing /etc/mail/sendmail.mc, aren’t we?

Where exactly do you see if happening?

Easy, go to Sendmail, Sendmail Options, and edit anything - eg Send Outgoing mail via host, add any host to it then Save and Apply.
Check the /etc/mail folder and the .cf will be updated but not the .mc.
If you then /etc/mail/update, the .cf will be generated from the unchanged .mc and the .cf loses the change that you just made in webmin.
So you have to use either one or the other. Forever.
Edit anything on the Sendmail Options screen, same thing happens.

@Jamie, is this something expected? Could you comment on this please?

Unfortunately it’s not possible for Webmin to safely edit the .mc file, because the format is just too complex - it’s almost a programming language in of itself! I looked into this years ago, but concluded that basically cannot be done.

I don’t see the problem?

Looking at your Sendmail Config page there are 29 items that are mostly:
Select Default or insert a value.
We only need to edit those values, not make a .mc file from scratch.
If line exists, remove dnl and change the value, if not add the line.

[heresy]
I made a short AI prompt and fed it to both Chat-GPT and Claude - both free versions. Chat-GPT kept sabotaging it, endless edit and corrections going nowhere. Claude needed 2 goes, first time it made for debian style even though I stated Rocky. Second go it worked.
I later did a bigger prompt with more stuff in it but ran into Claude limitations, mainly chat is too long, start a new one. I don’t know if that limitation goes away with paid version as it didn’t like my credit card - which works perfectly well everywhere else.
Can I post the simple test prompt here so that anyone interested can try it?
[/heresy]

Can you post an example of how those look in your sendmail.mc file?

Just for a test I had it edit 2 items.

Before and after.
dnl define(`SMART_HOST', `smtp.your.provider')dnl
define(`SMART_HOST', `mail1.domain.com')dnl

dnl define(`confLOG_LEVEL', `9')dnl
define(`confLOG_LEVEL', `8')dnl

What’s interesting is the log level item has a drop down listing error levels 0-9 with a comment about each level - which I did not ask for, but I like the concept.

  1. Serious system failure
  2. Lost communication
  3. Other serious failures
  4. Minor failures
  5. Message collection stats
  6. Creation of error messages
  7. Delivery failures
  8. Successful deliveries
  9. Messages being deferred

Claude also added a Raw sendmail.mc Editor which I had only suggested as a future option.

FYI, there is a fault in the original sendmail.mc provided for Rocky 9.5

FEATURE(`no_default_msa', `dnl')dnl

The 'dnl' inside the brackets shouldn’t be there.

Which page in Webmin did you do this on? Was it the “Sendmail M4 Configuration” page in the Sendmail module?

I figured that most of the edits that end up in the .cf are made by the module Sendmail Options, though I know that other modules will also make changes to it.

This was just a proof of concept, that the .mc could be edited then compiled to the .cf

The created module (Sendmail MC configuration) is based on Sendmail Options, but the editor was just a thought bubble originally.

This is the prompt that I used:

02-06-25, 20:21pm
Rocky9 - Enterprise Linux, Webmin 2.400
Concept:
I want to create a custom Webmin module for Sendmail that edits specific options in the sendmail.mc file — starting with SMART_HOST and confLOG_LEVEL.
The module should:
    Only edit known define(...) settings in sendmail.mc (not sendmail.cf)
    Remove dnl if the setting is commented
    Add the setting if it doesn’t already exist
    Back up both sendmail.mc and sendmail.cf before applying changes (e.g., with -00, -01, etc.)
    Run make -C /etc/mail to regenerate sendmail.cf
    Optionally include a raw text editor tab for .mc
For SMART_HOST, I want to be able to:
    Set it to a mail relay like smtp.example.com
    Disable it (i.e., “Deliver directly”), which should comment out or remove the SMART_HOST line
Please build this from scratch — starting with a minimal, working version that handles these two options cleanly.

The only thing I needed to correct was that it used /usr/share/webmin for the module instead of /usr/libexec/webmin, so that needs to be specified for RHEL variants - it has made this mistake every time I have done similar tests despite specifying Rocky9, EL, Enterprise Linux, or RHEL, so add that if you want to try this prompt. Being AI, you may get a completely different result.