sendmail (or postfix) is always failing with Helo command rejected

On digitalOcean this tutorial points to installing postfix. I've attempted this and also uninstalling postfix then installing sendmail

When a test mail is sent, invariably there is an error in identifying the sender

 451 4.7.1 <m-dev>:  Helo command rejected: HELO string 'm-dev' does not match last HELO string 'theactual.ws' from this IP *(when testing with sendmail)*

[with postfix it complains about it being sent by no-reply@m-dev...]

The tutorial suggests The System mail name must be the same as the name you assigned to your server. But that is simplistic, and has a high probability of not being respected.

Well, the domain name was not assigned to the server. hostname does return the assigned m-dev name.

How can Ubuntu 20.04 be set-up to use a FQDN that actually points to this server (+ has SPF and DKIM configurations set) ?

When attempting with postfix the postfix -n returns

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
inet_interfaces = all
inet_protocols = loopback-only
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = localhost.$mydomain, localhost, $myhostname
myhostname = m-dev
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may

Solution 1:

Other mail servers on the Internet generally expect your server to identify itself using its fully qualified domain name, and for the relevant forward and reverse DNS records to match. This does not require any special Postfix configuration on Linux systems which already have their hostname set to the FQDN, but Debian chose to use only an unqualified hostname (which causes a lot of other issues that have to be worked around, this being one of them).

First, you will need to decide what the fully qualified domain name is for this machine. It must not be a naked domain name. Once you have done that, you need to set the DNS address records for that name to the IPv6 and IPv4 addresses of your system, set the PTR records for those addresses to that FQDN, and finally in Postfix, set myhostname to the FQDN.

Finally, if that mail server has remembered something else as your FQDN, (which itself is quite unusual) you will probably have to wait for it to forget before you are able to send mail to it again.