I want to extract the sequence of numbers present in the mailbox using imap php. here is my code but it only reads the header of the message. help me
<?php
date_default_timezone_set('Asia/Ho_Chi_Minh');
error_reporting(0);
if (isset($_GET['usermail'])) {
$hostname = '{imap.yandex.com:993/imap/ssl/novalidate-cert}INBOX';
$username = $_GET['usermail'];
$password = $_GET['passmail'];
$mail = $_GET['mail'];
if ($username !="" && $password !="") {
$errorconnect =
[
"status"=>'false',
"msg"=>'NotConnect'
];
$inbox = imap_open($hostname,$username,$password) or die("Errorlogin");
$emails = imap_search($inbox,'TO "'.$mail.'"');
if($emails) {
$output = '';
rsort($emails);
foreach($emails as $email_number) {
$overview = imap_fetch_overview($inbox,$email_number,0);
$structure = imap_fetchstructure($inbox, $email_number);
$getsub = imap_utf8($overview[0]->subject);
$cutt = explode(" ", $getsub);
$output = $cutt[0];
}
echo "Facebook:".$output;
}
else
{
echo "errorinbox";
}
imap_close($inbox);
}
else
{
echo "Error";
}
}
?>
The content of the message looks like this:
Xin chào ABC!
Gần đây, bạn đã thêm acb@domain vào tài khoản Facebook của mình.
Vui lòng xác nhận địa chỉ email này để chúng tôi có thể cập nhật thông tin liên hệ của bạn.
Bạn có thể được yêu cầu nhập mã xác nhận sau: 21635.
Xác nhận
Trân trọng cảm ơn!
Đội ngũ Facebook
I want to extract "21635" it can be random from 5 numbers to 8 numbers.