diff --git a/inc/mailcollector.class.php b/inc/mailcollector.class.php index 8bc6f527bab..ab795c97048 100644 --- a/inc/mailcollector.class.php +++ b/inc/mailcollector.class.php @@ -1033,7 +1033,11 @@ function buildTicket($uid, \Laminas\Mail\Storage\Message $message, $options = [] $tkt['_do_not_check_users_id'] = 1; $body = $this->getBody($message); - $subject = $message->subject; + try { + $subject = $message->getHeader('subject')->getFieldValue(); + } catch (Laminas\Mail\Storage\Exception\InvalidArgumentException $e) { + $subject = null; + } $tkt['_message'] = $message; if (!Toolbox::seems_utf8($body)) { diff --git a/tests/emails-tests/16-no-subject.eml b/tests/emails-tests/16-no-subject.eml new file mode 100644 index 00000000000..101f0a07155 --- /dev/null +++ b/tests/emails-tests/16-no-subject.eml @@ -0,0 +1,27 @@ +Return-Path: normal@glpi-project.org +Received: from 192.168.1.3 (LHLO mail.glpi-project.org) (192.168.1.3) + by mail.glpi-project.org with LMTP; Thu, 11 Jul 2019 14:36:19 +0200 + (CEST) +Received: from mail.glpi-project.org (localhost [127.0.0.1]) + by mail.glpi-project.org (Postfix) with ESMTP id E93F77E80CDC + for ; Thu, 11 Jul 2019 14:36:19 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by mail.glpi-project.org (Postfix) with ESMTP id DDBE07E80832 + for ; Thu, 11 Jul 2019 14:36:19 +0200 (CEST) +Received: from mail.glpi-project.org ([127.0.0.1]) + by localhost (mail.glpi-project.org [127.0.0.1]) (amavisd-new, port 10026) + with ESMTP id 5TmiDey5TKGa for ; + Thu, 11 Jul 2019 14:36:19 +0200 (CEST) +Received: from mail.glpi-project.org (localhost [127.0.0.1]) + by mail.glpi-project.org (Postfix) with ESMTP id CAB177E806B4 + for ; Thu, 11 Jul 2019 14:36:19 +0200 (CEST) +Date: Thu, 11 Jul 2019 14:36:19 +0200 (CEST) +From: Normal User +To: GLPI debug +Message-ID: <799153164.8345898.1562848579774.JavaMail.zimbra@glpi-project.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 7bit +X-Mailer: Zimbra 8.0.9_GA_6191 (ZimbraWebClient - FF67 (Linux)/8.0.9_GA_6191) + +This is a mail without subject. diff --git a/tests/imap/MailCollector.php b/tests/imap/MailCollector.php index 18e59b92ddd..db9a1cf8386 100644 --- a/tests/imap/MailCollector.php +++ b/tests/imap/MailCollector.php @@ -320,7 +320,7 @@ public function testCollect() { ] ]); - $this->integer(count($iterator))->isIdenticalTo(8); + $this->integer(count($iterator))->isIdenticalTo(9); $names = []; while ($data = $iterator->next()) { $names[] = $data['name']; @@ -336,6 +336,7 @@ public function testCollect() { 'проверка', 'тест2', 'Inlined image with no Content-Disposition', + 'This is a mail without subject.', // No subject = name is set using ticket contents ]; $this->array($names)->isIdenticalTo($expected_names);