Repository: barbushin/php-imap

Issue #358: [BUG] TextHTML and TextPlain Empty
Created: 2019-06-21T15:34:06Z
Environment (please complete the following information):


PHP IMAP version: 3.0.26


PHP Version:
PHP 7.3.6-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:06:48) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.6-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies


Type of execution: cli


Describe the bug
TextHTML and TextPlain are empty if attachments are added. Mail was sent using thunderbird. Provider is Protonmail
To Reproduce
Send mail using protonmail to another e-mail provider with attachment and read it out from PHP-imap
The used code:
$mailbox = new PhpImap\Mailbox('{' . $imaphost . ':' . $imapport . $imapflag . '}' . $imapfolder, $imapuser, $imappass,  './cache/e-mailforwarder/');

$mails_ids = $mailbox->searchMailbox('UNSEEN');
foreach ($mails_ids as $mail_id) {
    $email = $mailbox->getMail($mail_id,true);
    if ($email->textHtml) {
        $mailContent = $email->textHtml;
        $mailIsHtml = true;
    } else {
        $mailContent = $email->textPlain;
        $mailIsHtml = false;
    }
}
The headers of the parsed email, if required and possible (only, if it's NOT confidential):
Return-Path: <xxxxx@xxxxx.be>
Delivered-To: xxxxx@xxxxx.be
Received: from web1.futureweb.be
    by web1.futureweb.be with LMTP
    id MJ7PARPhDF1YdgAAGc4NIw
    (envelope-from <xxxxx@xxxxx.be>)
    for <xxxxx@xxxxx.be>; Fri, 21 Jun 2019 15:52:19 +0200
Return-path: <xxxxx@xxxxx.be>
Envelope-to: xxxxx@xxxxx.be
Delivery-date: Fri, 21 Jun 2019 15:52:19 +0200
Received: from mail by web1.futureweb.be with spam-scanned (Exim 4.92)
    (envelope-from <xxxxx@xxxxx.be>)
    id 1heJxi-0007wH-Mb
    for xxxxx@xxxxx.be; Fri, 21 Jun 2019 15:52:18 +0200
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on web1.futureweb.be
X-Spam-Level:
X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
    DKIM_VALID_AU,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.1
Received: from mx1.futureweb.be ([185.70.72.82])
    by web1.futureweb.be with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
    (Exim 4.92)
    (envelope-from <xxxxx@xxxxx.be>)
    id 1heJxi-0007wD-Jc
    for xxxxx@xxxxx.be; Fri, 21 Jun 2019 15:52:18 +0200
X-Futureweb-MailScanner-EFA-Watermark: 1561729934.42052@6zwiC5xzFPA7BoUdz1FLVQ
X-Futureweb-MailScanner-EFA-From: xxxxx@xxxxx.be
X-Futureweb-MailScanner-EFA: Found to be clean
X-Futureweb-MailScanner-EFA-ID: 96413140EC0.A6169
X-Futureweb-MailScanner-EFA-Information: Please contact system@futureweb.be for more information
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0
Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22])
    (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
    (No client certificate requested)
    by mx1.futureweb.be (Postfix) with ESMTPS id 96413140EC0
    for <xxxxx@xxxxx.be>; Fri, 21 Jun 2019 15:52:13 +0200 (CEST)
Date: Fri, 21 Jun 2019 13:52:04 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeroened.be;
    s=protonmail; t=1561125132;
    bh=n9V3qIn1ZCYSaKFPkKsUvKB9FZxZXSdkZ5ibG8Ow+Wo=;
    h=Date:To:From:Reply-To:Subject:Feedback-ID:From;
    b=fGNjkx8DzoBEgcm1cA5ylfaIddaxUtpuy3D3sngY8OlIcDvovgI6DZtERqIJkJ38K
    f2aPECOj0I4xM4Ka+RzY6sJzsCfP5TIG3Ey8kCT45nGF2rBVG6077PD+cESRcwMYuQ
    fkqGbHaZsxbBSQb9RQa02GDgUNueoaKU+Gb8JlEA=
To: xxxxx@xxxxx.be
From: Jeroen De Meerleer <xxxxx@xxxxx.be>
Reply-To: Jeroen De Meerleer <xxxxx@xxxxx.be>
Subject: Tijdelijk test-mailadres voor info-adres
Message-ID: <PjqU-hMWAn0nA6RmOILCWUKD9aAgwzLlTtBZnjhuYY2ESOzVuoeomJYaVOdUDtOlej8Dr2dhagSAM0pVl8OHkj7Q1QlDyBC8SsgrIdkHXWg=@jeroened.be>
Feedback-ID: Dybr7i0cw-CMcdqF7mYoGYied0jEpIWVaPaH1oDb5hAOUUwhz_1Fpso6RC2t1PFoM47txuqbim-trLwoAbZEqw==:Ext:ProtonMail
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="b1_3e6c999a8becb14694a21f75923531cf"

e-mailaddresses removed
Expected behavior
TextHTML should contain the html body
Screenshots / Outputs
$mailContent = $email->textHtml;
echo $mailContent // Returns empty string
Additional context
Mail send with thunderbird. Provider is Protonmail. Intermediate app: protonmail bridge.
Unknown MDA. I guess it's dovecot. It returns * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN] Dovecot DA ready. upon telnet connection

Duplicate issue #364: textHtml is empty when attaching an image
Created: 2019-07-09T08:39:36Z
Faced a problem: when sending a letter with text and image attachment. The image is saved, and the text of the letter is empty.
In the process of studying, I found out that if the image is inserted directly into the text of the letter, then everything is fine. However, if the image is simply attached, the text of the letter is missing.
Studying the code made such an edit  (Mailbox.php, line 1009).
It was:
$this->initMailPart($mail, $subPartStructure, $partNum, $markAsSeen);
It became:
$this->initMailPart($mail, $subPartStructure, $partNum.'.'.($subPartNum + 1), $markAsSeen);
Apologize for my bad english

Closing comment (2019-07-09T09:25:20Z): Might be related to #358.