You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading messages from Gmail Sent folder, all messages are read with empty body (getHTMLBody/getTextBody methods return NULL or sometimes empty string, getRawBody return empty string).
$cm = newClientManager([
'options' => [
'fetch' => \Webklex\PHPIMAP\IMAP::FT_PEEK,
'sequence' => \Webklex\PHPIMAP\IMAP::ST_UID,
'fetch_body' => true,
'fetch_flags' => false,
'soft_fail' => true,
'rfc822' => true, // tried false tooo, no change'debug' => true,
'uid_cache' => false,
'fetch_order' => 'asc',
'common_folders' => [
"root" => "INBOX"
],
'decoder' => [
'message' => 'utf8', // mimeheader'attachment' => 'utf8'// mimeheader
],
]
]);
$client = $cm->make([..gmail..]);
$client->connect();
$folder = $client->getFolder('test'); // Sent or any other non-inbox folder$messages = $folder->messages()->all()->get();
foreach($messagesas$message) {
// all null or empty string, for all messages. besides of body, other mail attributes are OKvar_dump($message->getHTMLBody(),$message->getTextBody(),$message->getRawBody());
}
DEBUG output (compressed/skipped actual messages)
after headers of all messages are successfully fetched, body is fetched empty
ends with TAG8 NO System Error (Failure)
OK Gimap ready for requests from 164.215.118.74 dn12mb12278152wmb
TAG1 LOGIN "[email protected]" "xxxxx"
<< * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
TAG1 OK [email protected] authenticated (Success)
>> TAG2 LIST "" "*"
<< * LIST (\HasNoChildren) "/" "Error maily"
<< * LIST (\HasNoChildren) "/" "INBOX"
<< * LIST (\HasChildren \Noselect) "/" "Odlo&AX4-eno"
<< * LIST (\HasNoChildren) "/" "Odlo&AX4-eno/n&ARs-kdy"
<< * LIST (\HasChildren \Noselect) "/" "[Gmail]"
<< * LIST (\HasNoChildren \Important) "/" "[Gmail]/D&AW8-le&AX4-it&AOk-"
<< * LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Koncepty"
<< * LIST (\HasNoChildren \Trash) "/" "[Gmail]/Ko&AWE-"
<< * LIST (\HasNoChildren \Sent) "/" "[Gmail]/Odeslan&AOE- po&AWE-ta"
<< * LIST (\HasNoChildren) "/" "test"
<< TAG2 OK Success
>> TAG3 LIST "" "*"
<< * LIST (\HasNoChildren) "/" "Error maily"
<< * LIST (\HasNoChildren) "/" "INBOX"
<< * LIST (\HasChildren \Noselect) "/" "Odlo&AX4-eno"
<< * LIST (\HasNoChildren) "/" "Odlo&AX4-eno/n&ARs-kdy"
<< * LIST (\HasChildren \Noselect) "/" "[Gmail]"
<< * LIST (\HasNoChildren \Important) "/" "[Gmail]/D&AW8-le&AX4-it&AOk-"
<< * LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Koncepty"
<< * LIST (\HasNoChildren \Trash) "/" "[Gmail]/Ko&AWE-"
<< * LIST (\HasNoChildren \Sent) "/" "[Gmail]/Odeslan&AOE- po&AWE-ta"
<< * LIST (\Flagged \HasNoChildren) "/" "[Gmail]/S hv&ARs-zdi&AQ0-kou"
<< * LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
<< * LIST (\All \HasNoChildren) "/" "[Gmail]/V&AWE-echny zpr&AOE-vy"
<< * LIST (\HasNoChildren) "/" "test"
<< TAG3 OK Success
>> TAG4 SELECT "test"
<< * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing)
<< * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing \*)] Flags permitted.
<< * OK [UIDVALIDITY 59] UIDs valid.
<< * 50 EXISTS
<< * 0 RECENT
<< * OK [UIDNEXT 151] Predicted next UID.
<< * OK [HIGHESTMODSEQ 5191349]
<< TAG4 OK [READ-WRITE] test selected. (Success)
>> TAG5 UID SEARCH ALL
<< * SEARCH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
<< TAG5 OK SEARCH completed (Success)
>> TAG6 UID FETCH 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85 (FLAGS)
<< * 1 FETCH (UID 1 FLAGS (\Seen))
.......... 50 messages - all ok
<< TAG6 OK Success
>> TAG7 UID FETCH 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85 (RFC822.HEADER)
<< * 1 FETCH (UID 1 RFC822.HEADER {636}
.......... 50 messages - all ok
<< TAG7 OK Success
>> TAG8 UID FETCH 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85 (RFC822.TEXT)
<< TAG8 NO System Error (Failure)
array(0) {
}
>> TAG9 UID FETCH 1:* (UID)
<< * 1 FETCH (UID 1)
...
Finally found solution (code hack) to overcome this problem
ImapProtocol.php
Though solution works for me, I cannot prepare 'clean' pull request respecting architecture and options
this should probably be used in case of rfc822=false (or by some other option), but in message parseBody(), "RFC822" is hardcoded
OS: Debian 11
PHP: 8.0
Version 4.1.0
Provider: Gmail
The text was updated successfully, but these errors were encountered:
pavel-j
changed the title
Body is NULL when reading from Gmail folders
Body is NULL when reading from Gmail folders - working solution/code hack
Nov 15, 2022
When reading messages from Gmail Sent folder, all messages are read with empty body (getHTMLBody/getTextBody methods return NULL or sometimes empty string, getRawBody return empty string).
DEBUG output (compressed/skipped actual messages)
Finally found solution (code hack) to overcome this problem
ImapProtocol.php
This led me to my solution
https://forum.aspose.com/t/fetch-message-via-imap-use-body-rather-than-rfc822/251835
Though solution works for me, I cannot prepare 'clean' pull request respecting architecture and options
OS: Debian 11
PHP: 8.0
Version 4.1.0
Provider: Gmail
The text was updated successfully, but these errors were encountered: