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.23k stars 1.29k forks source link

10.0.10 - Mail receiver - PHP undefined variable $data on IMAP #16085

Closed JordanReich closed 7 months ago

JordanReich commented 11 months ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.10

Bug description

I have (2) issues in GLPI that I believe are related. We ingest most tickets through email and a minority through the Service Catalog (form) offerings.

Relevant log output

When checking the php-errors.log file in GLPI I am seeing the following information --

[2023-11-27 23:08:02] glpiphplog.WARNING:   *** PHP Warning (2): Undefined variable $data in /var/www/html/glpi/vendor/laminas/laminas-mail/src/Protocol/Imap.php at line 598
  Backtrace :
  ...r/laminas/laminas-mail/src/Storage/Imap.php:162 Laminas\Mail\Protocol\Imap->fetch()
  ...r/laminas/laminas-mail/src/Storage/Part.php:175 Laminas\Mail\Storage\Imap->getRawContent()
  ...r/laminas/laminas-mail/src/Storage/Part.php:249 Laminas\Mail\Storage\Part->cacheContent()
  ...r/laminas/laminas-mail/src/Storage/Part.php:471 Laminas\Mail\Storage\Part->countParts()
  src/MailCollector.php:1600                         Laminas\Mail\Storage\Part->rewind()
  src/MailCollector.php:1771                         MailCollector->getRecursiveAttached()
  src/MailCollector.php:1075                         MailCollector->getAttached()
  src/MailCollector.php:814                          MailCollector->buildTicket()
  src/MailCollector.php:1913                         MailCollector->collect()
  src/CronTask.php:1018                              MailCollector::cronMailgate()
  front/cron.php:84                                  CronTask::launch()

Page URL

N.A.

Steps To reproduce

Setup an IMAP email receiver IMAP, -----, NO-TLS, NO-VALIDATE-CERT, -----, -----, DEBUG

Your GLPI setup information

Information about system installation & configuration
GLPI 10.0.10 ( => /var/www/html/glpi)
Installation mode: TARBALL
Current language:en_US

Server
 
Operating system: Linux vs-gpli 5.15.0-88-generic #​98-Ubuntu SMP Mon Oct 2 15:18:56 UTC 2023 x86_64
PHP 8.1.2-1ubuntu2.14 apache2handler (Core, FFI, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bz2,
    calendar, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imagick, imap, intl, json, ldap,
    libxml, mbstring, memcache, mysqli, mysqlnd, openssl, pcre, pdo_mysql, posix, pspell, readline, session, shmop, sockets, sodium,
    standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="30" memory_limit="128M" post_max_size="8M" safe_mode="" session.save_handler="files"
    upload_max_filesize="2M" 
Software: Apache/2.4.52 (Ubuntu) (Apache/2.4.52 (Ubuntu) Server at support.reichnetwork.com Port 80
)
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Server Software: MySQL Community Server - GPL
    Server Version: 8.1.0
    Server SQL Mode: STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
    Parameters: glpiv2@10.0.0.83/glpidb
    Host info: 10.0.0.83 via TCP/IP

PHP version (8.1.2-1ubuntu2.14) is supported.
Sessions configuration is OK.
Allocated memory is sufficient.
mysqli extension is installed.
Following extensions are installed: dom, fileinfo, filter, libxml, json, simplexml, xmlreader, xmlwriter.
curl extension is installed.
gd extension is installed.
intl extension is installed.
zlib extension is installed.
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
Database engine version (8.1.0) is supported.
No files from previous GLPI version detected.
The log file has been created successfully.
Write access to /var/www/html/glpi/files/_cache has been validated.
Write access to /var/www/html/glpi/config has been validated.
Write access to /var/www/html/glpi/files/_cron has been validated.
Write access to /var/www/html/glpi/files has been validated.
Write access to /var/www/html/glpi/files/_dumps has been validated.
Write access to /var/www/html/glpi/files/_graphs has been validated.
Write access to /var/www/html/glpi/files/_lock has been validated.
Write access to /var/www/html/glpi/files/_pictures has been validated.
Write access to /var/www/html/glpi/files/_plugins has been validated.
Write access to /var/www/html/glpi/files/_rss has been validated.
Write access to /var/www/html/glpi/files/_sessions has been validated.
Write access to /var/www/html/glpi/files/_tmp has been validated.
Write access to /var/www/html/glpi/files/_uploads has been validated.

Web server root directory configuration seems safe.
Sessions configuration is secured.
OS and PHP are relying on 64 bits integers.
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
Following extensions are installed: bz2, Phar, zip.
Zend OPcache extension is installed.
Following extensions are installed: ctype, iconv, mbstring, sodium.
Write access to /var/www/html/glpi/marketplace has been validated.
Access to timezone database (mysql) is not allowed.

GLPI constants
 
GLPI_ROOT: "/var/www/html/glpi"
GLPI_CONFIG_DIR: "/var/www/html/glpi/config"
GLPI_VAR_DIR: "/var/www/html/glpi/files"
GLPI_MARKETPLACE_DIR: "/var/www/html/glpi/marketplace"
GLPI_USE_CSRF_CHECK: "1"
GLPI_CSRF_EXPIRES: "7200"
GLPI_CSRF_MAX_TOKENS: "100"
GLPI_USE_IDOR_CHECK: "1"
GLPI_IDOR_EXPIRES: "7200"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["/^(https?|feed):\\/\\/[^@:]+(\\/.*)?$/"]
GLPI_TELEMETRY_URI: "https://telemetry.glpi-project.org"
GLPI_INSTALL_MODE: "TARBALL"
GLPI_NETWORK_MAIL: "glpi@teclib.com"
GLPI_NETWORK_SERVICES: "https://services.glpi-network.com"
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: "0"
GLPI_CENTRAL_WARNINGS: "1"
GLPI_DOC_DIR: "/var/www/html/glpi/files"
GLPI_CACHE_DIR: "/var/www/html/glpi/files/_cache"
GLPI_CRON_DIR: "/var/www/html/glpi/files/_cron"
GLPI_DUMP_DIR: "/var/www/html/glpi/files/_dumps"
GLPI_GRAPH_DIR: "/var/www/html/glpi/files/_graphs"
GLPI_LOCAL_I18N_DIR: "/var/www/html/glpi/files/_locales"
GLPI_LOCK_DIR: "/var/www/html/glpi/files/_lock"
GLPI_LOG_DIR: "/var/www/html/glpi/files/_log"
GLPI_PICTURE_DIR: "/var/www/html/glpi/files/_pictures"
GLPI_PLUGIN_DOC_DIR: "/var/www/html/glpi/files/_plugins"
GLPI_RSS_DIR: "/var/www/html/glpi/files/_rss"
GLPI_SESSION_DIR: "/var/www/html/glpi/files/_sessions"
GLPI_TMP_DIR: "/var/www/html/glpi/files/_tmp"
GLPI_UPLOAD_DIR: "/var/www/html/glpi/files/_uploads"
GLPI_INVENTORY_DIR: "/var/www/html/glpi/files/_inventories"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/marketplace/"
GLPI_I18N_DIR: "/var/www/html/glpi/locales"
GLPI_VERSION: "10.0.10"
GLPI_SCHEMA_VERSION: "10.0.10@05de68add675fb55abaeec10f3a2552085594a16"
GLPI_MARKETPLACE_PRERELEASES: false
GLPI_MIN_PHP: "7.4.0"
GLPI_MAX_PHP: "8.4.0"
GLPI_YEAR: "2023"

Libraries
 
htmlawed/htmlawed version 1.2.14 in (/var/www/html/glpi/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.8.0 in (/var/www/html/glpi/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.8 in (/var/www/html/glpi/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.6.2 in (/var/www/html/glpi/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/var/www/html/glpi/vendor/michelf/php-markdown/Michelf)
true/punycode in (/var/www/html/glpi/vendor/true/punycode/src)
iamcal/lib_autolink in (/var/www/html/glpi/vendor/iamcal/lib_autolink)
sabre/dav in (/var/www/html/glpi/vendor/sabre/dav/lib/DAV)
sabre/http in (/var/www/html/glpi/vendor/sabre/http/lib)
sabre/uri in (/var/www/html/glpi/vendor/sabre/uri/lib)
sabre/vobject in (/var/www/html/glpi/vendor/sabre/vobject/lib)
laminas/laminas-i18n in (/var/www/html/glpi/vendor/laminas/laminas-i18n/src)
laminas/laminas-servicemanager in (/var/www/html/glpi/vendor/laminas/laminas-servicemanager/src)
monolog/monolog in (/var/www/html/glpi/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/var/www/html/glpi/vendor/sebastian/diff/src)
donatj/phpuseragentparser in (/var/www/html/glpi/vendor/donatj/phpuseragentparser/src/UserAgent)
elvanto/litemoji in (/var/www/html/glpi/vendor/elvanto/litemoji/src)
symfony/console in (/var/www/html/glpi/vendor/symfony/console)
scssphp/scssphp in (/var/www/html/glpi/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/var/www/html/glpi/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/var/www/html/glpi/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/var/www/html/glpi/vendor/rlanvin/php-rrule/src)
ramsey/uuid in (/var/www/html/glpi/vendor/ramsey/uuid/src)
psr/log in (/var/www/html/glpi/vendor/psr/log/Psr/Log)
psr/simple-cache in (/var/www/html/glpi/vendor/psr/simple-cache/src)
psr/cache in (/var/www/html/glpi/vendor/psr/cache/src)
league/csv in (/var/www/html/glpi/vendor/league/csv/src)
mexitek/phpcolors in (/var/www/html/glpi/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/var/www/html/glpi/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/var/www/html/glpi/vendor/guzzlehttp/psr7/src)
glpi-project/inventory_format in (/var/www/html/glpi/vendor/glpi-project/inventory_format/lib/php)
wapmorgan/unified-archive in (/var/www/html/glpi/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/var/www/html/glpi/vendor/paragonie/sodium_compat/src)
symfony/cache in (/var/www/html/glpi/vendor/symfony/cache)
html2text/html2text in (/var/www/html/glpi/vendor/html2text/html2text/src)
symfony/css-selector in (/var/www/html/glpi/vendor/symfony/css-selector)
symfony/dom-crawler in (/var/www/html/glpi/vendor/symfony/dom-crawler)
twig/twig in (/var/www/html/glpi/vendor/twig/twig/src)
twig/string-extra in (/var/www/html/glpi/vendor/twig/string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 not found
symfony/polyfill-php81 not found
symfony/polyfill-php82 in (/var/www/html/glpi/vendor/symfony/polyfill-php82)
league/oauth2-client in (/var/www/html/glpi/vendor/league/oauth2-client/src/Provider)
league/oauth2-google in (/var/www/html/glpi/vendor/league/oauth2-google/src/Provider)
thenetworg/oauth2-azure in (/var/www/html/glpi/vendor/thenetworg/oauth2-azure/src/Provider)
phpCas version 1.3.8 in (/usr/share/php/CAS/source)

LDAP directories
 
Server: '10.0.0.3', Port: '389', BaseDN: 'DC=ReichNetwork,DC=com', Connection filter: '(objectClass=user)', RootDN:
        'CN=svc_glpi,OU=Service,OU=Accounts,DC=ReichNetwork,DC=com', Use TLS: none

SQL replicas
 
Not active

Notifications
 
Way of sending emails: SMTP+TLS (support@reichnetwork.com@mail.reichnetwork.com)

Plugins list
 
    actualtime           Name: ActualTime                     Version: 2.2.0      State: Enabled                                 
        Install Method: Marketplace
    fields               Name: Additional Fields              Version: 1.21.6     State: Enabled                                 
        Install Method: Marketplace
    barcode              Name: Barcode                        Version: 2.7.1      State: Enabled                                 
        Install Method: Marketplace
    behaviors            Name: Behaviours                     Version: 2.7.2      State: Enabled                                 
        Install Method: Marketplace
    formcreator          Name: Form Creator                   Version: 2.13.7     State: Enabled                                 
        Install Method: Marketplace
    glpiinventory        Name: GLPI Inventory                 Version: 1.3.3      State: Enabled                                 
        Install Method: Marketplace
    oauthimap            Name: Oauth IMAP                     Version: 1.4.3      State: Enabled                                 
        Install Method: Marketplace
    order                Name: Orders management              Version: 2.10.4     State: Enabled                                 
        Install Method: Marketplace
    webhook              Name: Webhooks                       Version: 1.0.16     State: Enabled                                 
        Install Method: Marketplace

Anything else?

This problem was RESOLVED by switching the email protocol port from IMAP to POP. So, I'm unsure if this is a bug with the IMAP component or specific to my environment. Either way, it might be helpful to report the issue.

brlx74 commented 10 months ago

I think I am facing the same as problem (1), but slightly different: Mailcollector is obtaining a mail via IMAP, a few mails have no body, others from the same sender do have a body, the only difference I see betweeen these mails are a few Header-lines. I am adding some files for clarification, this is a Ticket where the Mail-Body was somehow removed: NoBodyMail This is a ticket from the same sender, it has a Body: MailwithBody And here are the Mail-Source files for reference: Mail with missing body: mailnobody.txt Mail with the body correctly displayed mailwithbody.txt

cconard96 commented 10 months ago

I think I am facing the same as problem (1), but slightly different

If you aren't seeing the same error in files/_log/php-errors.log as seen in the original bug report, you should open a separate bug report.

brlx74 commented 8 months ago

As of 10.0.12 i can not reproduce the "omitted body" behavior anymore

zzouhair10 commented 7 months ago

I have the same problem when my automatic collector collects the emails it creates the ticket without description just the title

php_error.log :

Warning: Undefined variable $data in E:\wamp64\www\glpi\vendor\laminas\laminas-mail\src\Protocol\Imap.php on line 598 PHP Stack trace: PHP 1. {main}() E:\wamp64\www\glpi\front\cron.php:0 PHP 2. CronTask::launch($mode = 2, $max = '10', $name = uninitialized) E:\wamp64\www\glpi\front\cron.php:84 PHP 3. MailCollector::cronMailgate($task = class CronTask { public $dohistory = TRUE; private $timer = 1709024373.1832; private $startlog = 16391571; private $volume = 0; public $fields = ['id' => 9, 'itemtype' => 'MailCollector', 'name' => 'mailgate', 'frequency' => 60, 'param' => 10, 'state' => 1, 'mode' => 2, 'allowmode' => 3, 'hourmin' => 0, 'hourmax' => 24, 'logs_lifetime' => 10, 'lastrun' => '2024-02-27 09:58:00', 'lastcode' => NULL, 'comment' => '', 'date_mod' => '2024-02-26 12:54:47', 'date_creation' => NULL, 'ISPLUGIN' => 0]; public $input = []; public $updates = []; public $oldvalues = []; public $history_blacklist = []; public $auto_message_on_action = TRUE; public $no_form_page = FALSE; public $additional_fields_for_dictionnary = []; protected $fkfield = ''; protected $searchopt = FALSE; public $taborientation = 'vertical'; public $get_item_to_display_tab = TRUE; protected $usenotepad = FALSE; public $deduplicate_queued_notifications = TRUE; public $right = NULL; protected $type = -1; protected $displaylist = TRUE; public $showdebug = FALSE }) E:\wamp64\www\glpi\src\CronTask.php:1018 PHP 4. MailCollector->collect($mailgateID = 6, $display = uninitialized) E:\wamp64\www\glpi\src\MailCollector.php:1852 PHP 5. MailCollector->buildTicket($uid = 30858, $message = class Laminas\Mail\Storage\Message { protected $flags = ['\Recent' => '\Recent']; protected $headers = class Laminas\Mail\Headers { private $headerLocator = class Laminas\Mail\Header\HeaderLocator { ... }; protected $pluginClassLoader = NULL; protected $headersKeys = [...]; protected $headers = [...]; protected $encoding = 'ASCII' }; protected $content = NULL; protected $topLines = ''; protected $parts = []; protected $countParts = 0; protected $iterationPos = 1; protected $mail = class Laminas\Mail\Storage\Imap { protected $protocol = class Laminas\Mail\Protocol\Imap { ... }; protected $currentFolder = 'INBOX'; protected $delimiter = NULL; protected $has = [...]; protected $iterationPos = 2; protected $iterationMax = 1; protected $messageClass = 'Laminas\Mail\Storage\Message' }; protected $messageNum = 1 }, $options = ['mailgates_id' => 6, 'play_rules' => TRUE]) E:\wamp64\www\glpi\src\MailCollector.php:767 PHP 6. MailCollector->getBody($message = class Laminas\Mail\Storage\Message { protected $flags = ['\Recent' => '\Recent']; protected $headers = class Laminas\Mail\Headers { private $headerLocator = class Laminas\Mail\Header\HeaderLocator { ... }; protected $pluginClassLoader = NULL; protected $headersKeys = [...]; protected $headers = [...]; protected $encoding = 'ASCII' }; protected $content = NULL; protected $topLines = ''; protected $parts = []; protected $countParts = 0; protected $iterationPos = 1; protected $mail = class Laminas\Mail\Storage\Imap { protected $protocol = class Laminas\Mail\Protocol\Imap { ... }; protected $currentFolder = 'INBOX'; protected $delimiter = NULL; protected $has = [...]; protected $iterationPos = 2; protected $iterationMax = 1; protected $messageClass = 'Laminas\Mail\Storage\Message' }; protected $messageNum = 1 }) E:\wamp64\www\glpi\src\MailCollector.php:1092 PHP 7. Laminas\Mail\Storage\Part->rewind() E:\wamp64\www\glpi\src\MailCollector.php:1742 PHP 8. Laminas\Mail\Storage\Part->countParts() E:\wamp64\www\glpi\vendor\laminas\laminas-mail\src\Storage\Part.php:471 PHP 9. Laminas\Mail\Storage\Part->cacheContent() E:\wamp64\www\glpi\vendor\laminas\laminas-mail\src\Storage\Part.php:249 PHP 10. Laminas\Mail\Storage\Imap->getRawContent($id = 1, $part = uninitialized) E:\wamp64\www\glpi\vendor\laminas\laminas-mail\src\Storage\Part.php:175 PHP 11. Laminas\Mail\Protocol\Imap->fetch($items = 'RFC822.TEXT', $from = 1, $to = uninitialized, $uid = uninitialized) E:\wamp64\www\glpi\vendor\laminas\laminas-mail\src\Storage\Imap.php:162

cedric-anne commented 7 months ago

@zzouhair10

Could you attach here an eml file that contains the email raw contents?

zzouhair10 commented 7 months ago

=-=-=-= Pour répondre par courriel, écrivez au dessus de cette ligne =-=-=-=

URL : https://partage/glpi/index.php?redirect=ticket_7438&noAUTO=1 Ticket : Description

Titre :Test Demandeurs : ZEBTA Zouhair Date d'ouverture :2024-02-27 09:16 Date de clôture : Source de la demande :E-Mail

Élément rattaché :

Statut  : Nouveau

Urgence : Moyenne Impact : Moyen Priorité : Moyenne

Pas de catégorie attribuée Description :

Nombre de suivis : 0 Nombre de tâches : 0

--

Généré automatiquement par GLPI

==== Pour répondre par courriel, écrivez en dessous de cette ligne ====

 Répondre

 Transférer Volet des participants fermé

cedric-anne commented 7 months ago

We need the source email into eml format to be able to inject it in the mail collector.

zzouhair10 commented 7 months ago

[GLPI #0007438] Nouveau ticket Test.zip

cedric-anne commented 7 months ago

I am not able to reproduce the issue.

As @JordanReich stated that he was able to fix its initial issue and as @brlx74 stated that his issue was resolved in GLPI 10.0.12, I consider the initial issue fixed.

@zzouhair10 If you still reproduce the issue in GLPI 10.0.12, please open a new issue with all requested details, including the source email that can be used to reproduce your issue (the email corresponding to the notification generated by GLPI does not really help).