1

Hello Im trying to get all email Attachments from my email inbox with the PHP Laminas Framework I tried this but it wouldn't work im not sure why... how do i extract attachments with laminas from emails?

    use Laminas\Mail\Storage\Imap;
    use Laminas\Mail\Exception;
    
    $mail = new Imap(array(
        'host'    => 'outlook.office365.com',
        'port'    => '993',
        'user'    => 'lorem@lorem.com',
        'password'    => 'lorem123',
        'ssl'    => 'SSL'));

    $numMessages = $mail->countMessages();
    
    while($numMessages) {
        $part = $mail->getMessage($numMessages);
        while ($part->isMultipart()) {
            $part = $mail->getPart(2);
        }
        echo 'type: ' . strtok($part->contentType, ';') . "\n";
        echo "content:\n";
        echo $part->getContent();
    }

fatal error: Uncaught Error: Call to undefined method Laminas\Mail\Storage\Imap::getPart() in /var/www/html/face/views/class.Email.php:94 Stack trace: #0 /var/www/html/face/inc/inc.ClassView.php(57): Face_View_Email->show() #1 /var/www/html/face/out/out.Email.php(20): Face_View->__invoke() #2 {main} thrown in /var/www/html/face/views/class.Email.php

DarkBee
  • 16,592
  • 6
  • 46
  • 58
smrtsremwsn
  • 23
  • 1
  • 6
  • Your loop appears infinite. You never change numMessages.... – Max Nov 02 '21 at 20:55
  • Yes you're right but this isn't the issue im looking for i already fixed that, something is wrong with the multipart thingy i think... it just doesn't work ... – smrtsremwsn Nov 03 '21 at 07:18
  • I'm getting: Fatal error : Uncaught Error: Call to undefined method Laminas\Mail\Storage\Imap::getPart() in ... – smrtsremwsn Nov 03 '21 at 08:20
  • Please start by editing your full error into your question so e can help. – Max Nov 03 '21 at 13:10

0 Answers0