Configure fqdn for nextcloud host

My mail server is configured to reject mail from hosts with no FQDN. The default configuration of the Mail App only uses the base host name, therefore I cannot send mail from NextCloud.

How do I configure the FQDN for the mail app?

Thanks in advance.

Using an intermediary MTA that fix the problem?
For example a local postfix server that act as a relay server.

Possible! Although that’s using a F-18 to shoot down a fly.

I’d be better off installing a webmail server!

I’m looking for a one liner…

1 Like

:smiley: I’m stealing that for later use

@tflidd any idea? Else ping the Mail app devs.

Aha! I knew I’d dealt with that problem once last year. I finally found my notes:


NextCloud uses the Horde libraries for the mail app. While I don’t know zilch about PHP I thought I would at least look at the code.

The interesting part is in apps/mail/vendor/

First there is a function _hello that does the EHLO exchange:

protected function _hello()
    $ehlo = $host = $this->_getHostname();
    if ($host === false) {
        $ehlo = $_SERVER['SERVER_ADDR'];
        $host = 'localhost';

We want the function _getHostname:

protected function _getHostname()
    return ($localhost = $this->getParam('localhost'))
        ? $localhost
        : gethostname();

It appears that the PHP builtin gethostname() can only return the non-qualified server host name. So what’s left is the function getParam.

getParam does things to a _params array. That takes us back to the top of the file where there is a constructor filling up a params array. And there is provision for a parameter named localhost. I figured I could play with the array too. So I added a line to force params(‘localhost’) to contain my fqdn:

public function __construct(array $params = array())
    // Default values.
    $params = array_merge(array(
        'chunk_size' => self::CHUNK_DEFAULT,
        'context' => array(),
        'host' => 'localhost',
        'port' => 587,
        'secure' => true,
        'timeout' => 30,
+        'localhost' => ''
    ), array_filter($params));

Save. Try sending. Bingo.

At best that’s a hack, not a fix; I’ll have to edit that file for every upgrade. Also it’s a known problem with Horde, although, at first glance, it does not seem to be an issue. Which implies that most SMTP servers out there are configured to accept mail from any host name. And we’re surprised at the prevalence of spam.


Should I file a bug?

Thanks everyone!

Please do file a bug :slight_smile:

Done. #6325.