Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mail app does not send fqdn #6325

Closed
pclerie opened this issue Aug 31, 2017 · 1 comment
Closed

mail app does not send fqdn #6325

pclerie opened this issue Aug 31, 2017 · 1 comment

Comments

@pclerie
Copy link

pclerie commented Aug 31, 2017

The Mail App fails when sending to a server configured to reject hosts with no FQDN. Below are some notes from trying to solve that problem:

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/pear-pear.horde.org/Horde_Smtp/Horde/Smtp.php.

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' => 'myhostname.example.com'
    ), 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.

@rullzer
Copy link
Member

rullzer commented Aug 31, 2017

Please fill this at https://github.com/nextcloud/mail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants