Solution 1:

On Debian, I have found that using mailx command from the mailutils package generates wrong "From" domain address - it calls sendmail with "-f" parameter specifying just the hostname without any domain.

When you install the bsd-mailx package, it provides its own version of the mail / mailx binary (which should be set automatically as the default alternative). This internally calls "sendmail" without the "-f" parameter and (when mail server is configured properly) uses the correct full hostname + domain.