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

Helo command rejected: need fully-qualified hostname #12007

Closed
netdesign opened this issue Sep 6, 2017 · 15 comments
Closed

Helo command rejected: need fully-qualified hostname #12007

netdesign opened this issue Sep 6, 2017 · 15 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@netdesign
Copy link

Googling my issue doesn't give any useful result so I submit this issue with attached the solution (as a screenshot). I hope it is useful.

The ISSUE in the suject is reproducible if:

  1. You use an external SMTP server to send Email reports
  2. Your external SMTP server requires fully-qualified-hostname EHLO/HELO from client to grant sending

The SMTP transport class included in the Piwik sources hardcodes the hostname to "localhost" instead of the true local hostname as required by RFC2821, RFC1869. This way the SMTP server refuses to send the report email.

The "Zend_Mail_Transport_Smtp" constructor provides a way to set custom configuration (such as the hostname) but the Piwik interface isn't able to set this variable.

Here I attach my solution :)

piwik-smtp-issue

@Globulopolis
Copy link
Contributor

SMTP server address in General settings is not it?

@netdesign
Copy link
Author

No, it isn't. The "SMTP server address" in "General settings" is the address of the SMTP server while the issue is related to the client (during smtp connection the client connects to the server, the server introduces itself and waits for the client to send its hostname, this kind of handshake is called HELO / EHLO).

You can get many details about the smtp connection steps and commands on http://www.samlogic.net/articles/smtp-commands-reference.htm

@Globulopolis
Copy link
Contributor

@netdesign problem not in the core Zend_Mail_Transport_Smtp. I see that the Mail->initSmtpTransport() do not use host value at all.
Piwik config.ini file contain host for mail transport but this is not a client hostname.
Maybe I can do PR for this.

@netdesign
Copy link
Author

netdesign commented Sep 8, 2017

Dear @Globulopolis, add the "client hostname" support in the Piwik config.ini would be an option, but I'm sure that setting "localhost" as default value in "$this->_name" is a fault because "localhost" is meaningless in the SMTP protocol (every host is localhost).

Even if you add the discussed variable in the Piwik config.ini, what would be the default value? What would happen if the user doesn't set the variable and leaves the software to choose it for him? It most likely will be "localhost" and the probem is here again (except that Piwik forces the user to set the value during the installation).

What I'd suggest is to report the issue to the upstream Zend team and adding, as just you said, the variable to the Piwik config.ini.

This will give the freedom to advanced users to set the "client hostname" to a custom value but will set automatically the variable with a meaningful value (the real hostname as known by the OS).

I hope you share my personal opinion.
Have a nice day ;)

Fabio (team Netdesign)

@bglxx
Copy link

bglxx commented Sep 8, 2018

Dear @Globulopolis, I dont want to change Zend files so I have changed /piwik/core/Mail.php, function initSmtpTransport

if (!empty($mailConfig['heloname'])) { $smtpConfig['name'] = $mailConfig['heloname']; }

and added "heloname = example.org" in my config.ini.php. Now it works correctly.

Greetings from Cologne - Bernd

@jtreml272
Copy link

Dear @bglxx would you be so kind and post your /piwik/core/Mail.php and config.ini.php.
I am trying to setup ma configs according to your advices but without success. Many thanks in advance. Josef

@netdesign
Copy link
Author

Hello @bglxx I'm very unhappy but I don't have success for the mail sending feature even following both actions suggested by you (on the latest Matomo version 3.13.3).

I fixed again the ISSUE this time chaning Zend library on:

/libs/Zend/Mail/Transport/Smtp.php

changing in the contructor:

    public function __construct($host = '127.0.0.1', Array $config = array())
    {
        if (isset($config['name'])) {
            $this->_name = $config['name'];
        } else {
            $this->_name = gethostname();
        }

Dear @Globulopolis, I dont want to change Zend files so I have changed /piwik/core/Mail.php, function initSmtpTransport

if (!empty($mailConfig['heloname'])) { $smtpConfig['name'] = $mailConfig['heloname']; }

and added "heloname = example.org" in my config.ini.php. Now it works correctly.

Greetings from Cologne - Bernd

netdesign pushed a commit to netdesign/matomo that referenced this issue Mar 8, 2020
@netdesign
Copy link
Author

May I make pull request related to 90d65ae ?

@tsteur
Copy link
Member

tsteur commented Mar 8, 2020

@netdesign feel free to create one. However, it may not be needed because as part of Matomo 4 we're replacing the Mailer library see #14841 and the change would likely be undone again. We're hoping the new mailer library will fix things like these right away.

@netdesign
Copy link
Author

@tsteur it seems that #14841 is into discussion yet. And target milestone is 4.0.0. Isn't it?

@tsteur
Copy link
Member

tsteur commented Mar 9, 2020

Yes, we already started working on Matomo 4 and I reckon we will be working on that issue soon.

For 3.X we're only fixing mostly regressions and security issues now while we focus on Matomo 4.

@netdesign
Copy link
Author

Yes, we already started working on Matomo 4 and I reckon we will be working on that issue soon.

For 3.X we're only fixing mostly regressions and security issues now while we focus on Matomo 4.

Ok @tsteur thank you for your updates!

@vsviridov
Copy link

Still affected by this, for some reason my matomo instance identifies with the server's IPv6 address, even though the host name is configured correctly.

@sgiehl
Copy link
Member

sgiehl commented Apr 19, 2023

Actually it's not possible that you are affected by the exact same error. The problem was how Zend Mail was working. But we meanwhile replace Zend Mail with PHPMailer.

PHPMailer actually allows to set the Hostname, but we currently don't do that. So PHPMailer might try to identify the hostname itself by checking $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value 'localhost.localdomain'.

We could add an additional configuration option though to allow overwriting the hostname...

@sgiehl sgiehl added this to the For Prioritization milestone Apr 19, 2023
@vsviridov
Copy link

vsviridov commented Apr 19, 2023

I see there's a defaultHostnameIfEmpty config under global.ini.php, I'll try to set that up and see if it helps...

Edit: This resolved my issue.

@sgiehl sgiehl closed this as completed Apr 19, 2023
@sgiehl sgiehl removed this from the For Prioritization milestone May 16, 2023
@sgiehl sgiehl added the answered For when a question was asked and we referred to forum or answered it. label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

7 participants