如何在php中使用imap在引导模式弹出窗口中显示Gmail正文消息?

如何在php中使用imap在引导模式弹出窗口中显示Gmail正文消息?,php,popup,gmail,bootstrap-modal,imap,Php,Popup,Gmail,Bootstrap Modal,Imap,我正在编写一个PHP脚本,当有人点击表tr时,我想用PHP中的IMAP在引导模式弹出窗口中显示Gmail body message,模式弹出窗口将显示body message 但目前的问题是,正文消息显示在模式弹出窗口之外 当我在imap\u fetchbody中尝试1number时,会在模式弹出窗口中显示它的屏幕截图 当我在imap\u fetchbody中尝试2number时,它显示在模式弹出窗口的外部 这里是它的截图 请指导我在哪里使用了错误的代码为什么我的源代码不能像examle那样

我正在编写一个PHP脚本,当有人点击
表tr
时,我想用PHP中的IMAP在引导模式弹出窗口中显示Gmail body message,模式弹出窗口将显示
body message

但目前的问题是,
正文消息
显示在模式弹出窗口之外

当我在
imap\u fetchbody
中尝试
1
number时,会在
模式弹出窗口中显示它的屏幕截图

当我在
imap\u fetchbody
中尝试
2
number时,它显示在
模式弹出窗口的外部
这里是它的截图

请指导我在哪里使用了错误的代码为什么我的源代码不能像examle那样工作

这里是我的代码

 <table id="example" class="display" cellspacing="0">
      <thead>
    
      <tr>
      <th>From</th>
      <th>Subject</th>                       
      <th>Date</th>
      </tr>
      </thead>
      <tfoot>
      
      <tr>
      <th>From</th>
      <th>Subject</th>                      
      <th>Date</th>
      </tr>
      </tfoot>
      <tbody>

           <?php
           $z=0;
           $hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
           $username = 'test@gmail.com';
           $password = 'test@123';

           $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());

           $emails = imap_search($inbox,'ALL');

           if($emails) {
               
               $output = '';
               rsort($emails);
               foreach($emails as $email_number) {
               $z++;
               $overview = imap_fetch_overview($inbox,$email_number,0);
               $structure = imap_fetchstructure($inbox, $email_number);
           
           if(isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
               
               $part = $structure->parts[1];
               $message = imap_fetchbody($inbox,$email_number,2);

               if($part->encoding == 3) {
                   $message = imap_base64($message);
               } else if($part->encoding == 1) {
                  $message = imap_8bit($message);
               } else {
                  $message = imap_qprint($message);
               }
               }?>

               <tr data-unqiue-id="<?php echo $z ?>" class="loadmessage_<?php echo $z ?>">
                   <td>
                   <?php echo utf8_decode(imap_utf8($overview[0]->from)) ?>
                   </td>

                   <td>
                   <?php echo utf8_decode(imap_utf8($overview[0]->subject)) ?>
                   </td>
                                       
                   <td>
                   <?php echo utf8_decode(imap_utf8($overview[0]->date)) ?>
                   </td>
                   </tr>


                   <div class="modal fade" id="emailmessage_<?php echo $z ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                           <div class="modal-dialog" role="document">
                           <div class="modal-content">
                           <div class="modal-header">
                           <h5 class="modal-title" id="exampleModalLabel">Email Message</h5>
                           <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                           <span aria-hidden="true">×</span>
                           </button>
                           </div>


                           <div class="modal-body">
                                 <?php echo $message ?>
                           </div>
                           </div>
                  </div>
                  </div>

                   <script>
                    $(document).ready(function() {
                    $(".loadmessage_<?php echo $z ?>").on("click", function(e) {
                       var loadmessage = $('.loadmessage_<?php echo $z ?>').attr("data-unqiue-id");
                    $('#emailmessage_'+loadmessage).modal('show');
                       });
                       });
                   </script>



                   <?php }
                     echo $output;
                   }

                   imap_close($inbox);
                   ?>

从…起
主题
日期
从…起
主题
日期