There is a script that receives letters in php. As soon as it receives the name of the folders that are created on the mailer. How can you modify it to get not only the names of folders but also the subject of the letter, addressees, and the body of the letter?

Here is an example script:

$mbox = imap_open("{imap.mail.ru.mail.ru:143}", "wwwwwwww", "wwwwww"); echo "<h1>Mailboxes</h1>\n"; $folders = imap_listmailbox($mbox, "{imap.mail.ru.mail.ru:143}", "*"); if ($folders == false) { echo "Call failed<br />\n"; } else { foreach ($folders as $val) { echo $val . "<br />\n"; } } echo "<h1>Headers in INBOX</h1>\n"; $headers = imap_headers($mbox); if ($headers == false) { echo "Call failed<br />\n"; } else { foreach ($headers as $val) { echo $val . "<br />\n"; } } imap_close($mbox); 

    1 answer 1

    There is a ready library for working with imap.

    https://github.com/gotha/PHP-IMAP-library/blob/master/MailLib.php

    You can see the implementation of the functional from him or the library itself and use