Hi, this is my working code:
$mail = new Imap([
'host' => 'mail.provider.com',
'port' => 993,
'user' => 'user@domain.com',
'password' => '123',
'ssl' => 'SSL'
]);
echo $mail->countMessages() . " messages found\n";
foreach ($mail as $message) {
echo $message->from.'</br>';
echo $message->subject.'</br>';
}
Im later using this loop to store the data on a DB.
But if i try to access the body or full source of the email, can’t find a way to do it.
I’ve tried:
$message->getContent()
$message->getBody()
$message->getBodyText()
Also tried doing a loop with $message->getParts() and then $part->getRawContent().
Particularly with $message->getContent() i get Undefined array key 0
.
My intention is to at least save full email source (the whole plain source) in a DB (or in a .txt file on my server).
On a second intention, would be to just store the whole text/html
part on my DB.
Any pointers on how to do it?
Thanks!