Email without commercial System Admin and with Sendmail not Postfix

My personal VM’s (and those of the charity I work with) are either Windows or Ubuntu, I do have one FreePBX Distro VM but it’s a pain because it’s different from all of the others.
The 3 PBX’s are all small and really don’t justify commercial licensing for the System Admin module. Anyway it seems that is only available for the Distro.
So how to get backup Emails out of FreePBX? Most of the web posts are about sending Email to public MTA’s, with authentication, and using Postfix. IMHO they are complex. Apart from the one “Distro” VM, the two others run plain Sendmail.
Emails from the backup module were not working on any of the three.

Editorial comment: I understand that Sangoma has to make money and pay staff. Hence commercial products and that’s great. It is wonderful that most of FreePBX is offered at no cost, including the Distro and source code that can be run on other Linux flavors (to my reading, reluctantly on Sangoma’s part). It’s nice that Email notifications - so essential! - are there for free. BUT: it’s really weird that you have to buy the commercial System Admin module to be able to CONFIGURE Email notifications. Unless you use Postfix and have a good bit of expertise to configure it. Sangoma, please at LEAST provide information on how to change the default FreePBX Email destination from localhost to something else!

It cost me a day but here is what I have gleaned. I am no expert and your mileage may vary.

  1. /etc/hosts has to be correct, 127.0.0.1 localhost localhost.{yourlocaldomain}
  2. We have separate internal and external DNS. internal.example.com resolves to our 10.x.x.x addresses. On the public internet, example.com resolves to our mail gateway etc. The FreePBX servers are obviously internal so I had to send backup Email to [email protected] rather than [email protected].
  3. I poked at the asterisk database in mysql and found one table / key that seemed relevant but changing it didn’t help. See editorial comment above …
  4. On our one FreePBX Distro - which by default runs Postfix - I set the following:
    In file main.cf:
myhostname = pbx.example.com
mydomain = example.com
inet_protocols = ipv4

In file transport:

internal.example.com : smtp:mainmailserver.internal.example.com
.internal.example.com : smtp:mainmailserver.internal.example.com
* : smtp:
  1. On the two Ubuntu systems that run FreePBX and Ubuntu. In one of them I had issues because firewall software was blocking SMTP internal to the box. On both:
    In /etc/mail/sendmail.mc added
define(`SMART_HOST', `mainmailserver.internal.example.com')

In /etc/mail/submit.mc added (note, the dnl # is commenting out an existing line)

dnl #FEATURE(`msp', `[127.0.0.1]', `25')dnl
FEATURE(`msp', `internal.example.com', `25')dnl

In /etc/mail/address.resolve - removed the example entries and added:

# addresses to be delivered locally
root            local:root
postmaster      local:root

This is the one issue I still have remaining. Something on the system is sending mail to “postmaster” and, sendmail is trying to forward it (without any @domain.suffix) to my server internal.example.com where it is obviously rejected. There is no obvious consequence but it would be nice not to have the log messages, so if someone has a solution I am all ears.

Mainly I am posting in the hope this will be save someone else some time.