glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.24k stars 1.29k forks source link

Mailgate fail after upgrade to 9.5 #7619

Closed tizianosartori closed 4 years ago

tizianosartori commented 4 years ago

`#0 /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Imap.php(216): Laminas\Mail\Protocol\Imap->connect('ssl://Gwr01', 993, 'ssl')

1 /var/www/glpi/inc/toolbox.class.php(2323): Laminas\Mail\Storage\Imap->__construct(Object(stdClass))

2 /var/www/glpi/inc/mailcollector.class.php(1290): Toolbox::getMailServerStorageInstance('imap', Array)

3 /var/www/glpi/inc/mailcollector.class.php(667): MailCollector->connect()

4 /var/www/glpi/inc/mailcollector.class.php(1725): MailCollector->collect(2)

5 /var/www/glpi/inc/crontask.class.php(847): MailCollector::cronMailgate(Object(CronTask))

6 /var/www/glpi/front/cron.php(83): CronTask::launch(2, '15')

7 {main} {"user":"@glpi"}

[2020-07-08 13:26:07] glpiphplog.ERROR: MailCollector::collect() in /var/www/glpi/inc/mailcollector.class.php line 669`

Mails receivers Name: 'Glpi@stetspa.it' Active: Yes Server: '{Gwr01/imap/ssl/novalidate-cert}INBOX' Login: 'glpi' Password: Yes

An error occured trying to connect to collector. cannot connect to host ; error = fsockopen(): unable to connect to ssl://Gwr01:993 (Unknown error) (errno = 0 )

trasher commented 4 years ago

You should check your imap server logs, and make sure connexion is ok from sever.

This looks like a network connection error rather than a GLPI issue; I close.

tizianosartori commented 4 years ago

The network is the same before the upgrade from 9.4. After upgrade mailcollector stop working.

trasher commented 4 years ago

OK, I cannot make any checks instead of you anyways. Error is your GLPI server cannot connect to Gwr01. There are test to do like using the IP instead of a host name, etc; to make sure everything is OK.

Feel free to reopen the issue when you have more information on how to reproduce.

tizianosartori commented 4 years ago

Maybe the new laminas-mail component ignore the NO-VALIDATE-CERT option?

trasher commented 4 years ago

No; and there is nothing in provided data that can let think about any SSL certificate. I guess it would not change anything you remove it.

tizianosartori commented 4 years ago

Without SSL on port 143 the error is:

[2020-07-08 16:24:47] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\RuntimeException: cannot login, user or password wrong in /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Imap.php at line 218 Backtrace : inc/toolbox.class.php:2323 Laminas\Mail\Storage\Imap->__construct() inc/mailcollector.class.php:1290 Toolbox::getMailServerStorageInstance() inc/mailcollector.class.php:667 MailCollector->connect() front/mailcollector.form.php:77 MailCollector->collect()

but i'm sure that the password is good. Maybe the field get not stored correctly on database?

tizianosartori commented 4 years ago

NO VALIDATE option was ignored

[2020-07-08 17:37:32] glpiphplog.WARNING: *** PHP Warning (2): stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /var/www/glpi/vendor/laminas/laminas-mail/src/Protocol/Imap.php at line 106

trasher commented 4 years ago

Sounds strange, this is used in IMAP unit tests, and as far as I remember, this was required; so that should work. I reopen the issue, no idea what's wrong.

Dayflare commented 4 years ago

i have this error too. [2020-07-09 11:42:39] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\RuntimeException: cannot login, user or password wrong in /var/www/html/glpi/vendor/laminas/laminas-mail/src/Storage/Imap.php at line 218

updated to 9.5.0 and mailgate doesn't work anymore. user and password are verified to be correct, i even changed the password for testing this. Before the update everything worked fine.

Mail Backend is Exchange 2013 on premise.

IMAP Log: "TAG1 BAD Command received in Invalid state."

cedric-anne commented 4 years ago

Hi,

Can you give us which params you are using here ? image

Regards

tizianosartori commented 4 years ago

I can confirm mailgate works if use a valid SSL certificate. I think the problem is the "NO VALIDATE" option.

cedric-anne commented 4 years ago

I can confirm mailgate works if use a valid SSL certificate. I think the problem is the "NO VALIDATE" option.

Indeed, looking at the code, this is not handled in the new dependency we use to replace usage of obsolete php-imap extension.

A solution may be to override the class to do something like https://github.com/laminas/laminas-mail/issues/63 .

I also figure that the 'norsh', 'secure' and 'debug' options may have no effet.

trasher commented 4 years ago

There were already a fix proposal on Zend-Mail; I've requested a new one (with same existing code); see: https://github.com/laminas/laminas-mail/pull/94

tizianosartori commented 4 years ago

Another error on same laminas component

[2020-07-10 11:49:10] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\InvalidArgumentException: Header with Name reply-to or reply-to not found in /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Part.php at line 307

I don't know if is a new issue or not.

husisusi commented 4 years ago

The same applies here! After Upgrade 9.4 to 9.5 Mailgate works for 20h (I made 5 E-mail tests) and after that get stuck. Recovered to 9.4 and it works again. Annoying!!

epeyron commented 4 years ago

Another error on same laminas component

[2020-07-10 11:49:10] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\InvalidArgumentException: Header with Name reply-to or reply-to not found in /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Part.php at line 307

I don't know if is a new issue or not.

Same error for me, GLPI 9.5.0 Help... :-)

cedric-anne commented 4 years ago

Another error on same laminas component

[2020-07-10 11:49:10] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\InvalidArgumentException: Header with Name reply-to or reply-to not found in /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Part.php at line 307

I don't know if is a new issue or not.

This is another issue and it has been fixed in #7652 (see #7643 ).

epeyron commented 4 years ago

Another error on same laminas component [2020-07-10 11:49:10] glpiphplog.CRITICAL: *** Uncaught Exception Laminas\Mail\Storage\Exception\InvalidArgumentException: Header with Name reply-to or reply-to not found in /var/www/glpi/vendor/laminas/laminas-mail/src/Storage/Part.php at line 307 I don't know if is a new issue or not.

This is another issue and it has been fixed in #7652 (see #7643 ).

Thanks !!! 👍 i have replace inc/mailcollector.class.php with the last fix

sector7gp commented 4 years ago

I recently updated to 9.5 using IMAP and works fine {mail.mydomain.com:993/imap/ssl/validate-cert}FOLDER

nectop commented 4 years ago

I recently updated to 9.5 using IMAP and works fine {mail.mydomain.com:993/imap/ssl/validate-cert}FOLDER

If you have not self-signed certificate it will. For example I have to use self-sighted certificate or from local Windows CA, it doesn't work. Furthermore, if you will disable certificate check it will produce an error in log, that login or password is wrong. (Mail Server Exchange 2010/2016).

husisusi commented 4 years ago

Interesting!

After upgrade from 9.4 to 9.5 I made www-data as owner for glpi folder recursive. After run: sudo -u www-data /usr/bin/php /var/www/html/glpi/front/cron.php I get:

Uncaught Exception Laminas\Cache\Exception\RuntimeException: Error opening file '/var/www/html/glpi/files/_cache/cache_trans/glpi_cache_trans_9.5.0ce6dddfb1e143d3cf64c47f81bba6781-38/glpi_cache_trans_9.5.0ce6dddfb1e143d3cf64c47f81bba6781-Laminas_I18n_Translator_Messages_31ebc1a09507bf4ac4680c9eb82c177a.dat' in /var/www/html/glpi/vendor/laminas/laminas-cache/src/Storage/Adapter/Filesystem.php at line 1581

after rerun "chown ww-data glpi/ -R" again, it works. Which user create this cache?

mrjd1981 commented 4 years ago

[2020-07-15 13:16:06] glpiphplog.CRITICAL: *** Uncaught Exception Error: Call to a member function getEmail() on bool in /var/www/html/inc/mailcollector.class.php at line 1407 Backtrace : inc/mailcollector.class.php:912 MailCollector->getHeaders() inc/mailcollector.class.php:711 MailCollector->buildTicket() inc/mailcollector.class.php:1725 MailCollector->collect() inc/crontask.class.php:847 MailCollector::cronMailgate() front/crontask.form.php:49 CronTask::launch()

Any ideas?

trasher commented 4 years ago

Which user create this cache?

The one you use.

Frequently, users setups cron with any default user (root...) and then does not understand why webserver cannot access logs or cache. BTW; this is not related to current issue.

trasher commented 4 years ago

See #7693; closing this one as it is very unclear and refers to several issues.

cedric-anne commented 4 years ago

[2020-07-15 13:16:06] glpiphplog.CRITICAL: *** Uncaught Exception Error: Call to a member function getEmail() on bool in /var/www/html/inc/mailcollector.class.php at line 1407 Backtrace : inc/mailcollector.class.php:912 MailCollector->getHeaders() inc/mailcollector.class.php:711 MailCollector->buildTicket() inc/mailcollector.class.php:1725 MailCollector->collect() inc/crontask.class.php:847 MailCollector::cronMailgate() front/crontask.form.php:49 CronTask::launch()

Any ideas?

I think is has been fixed yet in #7652.

steph461 commented 4 years ago

My news post #7790 it's the same problem

MathysLioson commented 1 year ago

I recently updated to 9.5 using IMAP and works fine {mail.mydomain.com:993/imap/ssl/validate-cert}FOLDER

If you have not self-signed certificate it will. For example I have to use self-sighted certificate or from local Windows CA, it doesn't work. Furthermore, if you will disable certificate check it will produce an error in log, that login or password is wrong. (Mail Server Exchange 2010/2016).

I have the same issue, there is any fix for that ? I'm on Exchange 2016 and GLPI 10.0.5

cedric-anne commented 1 year ago

@MathysLioson

Please open a new issue and give all requested information.