Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

XXX's avatar
Level 5

Filter latest reply from php imap

Hi,

I'm using the PHP imap lib. I have no problems pulling e-mails and reading the plain body. ($mail->textPlain). However this takes the entire body (including the conversation/history). I want to filter the history and only keep the reply. I tried using regex and that works fine for Gmail but for other email clients it doens't work. Does someone knows a workaround or a library?

preg_replace('#(^\w.+:\n)?(^>.*(\n|$))+#mi', "", $mail->textPlain);

I'm aware that php imap does not provide a method for that but I'm want to know if there are libraries for it.

0 likes
3 replies

Please or to participate in this conversation.