如何使用laravel在我的电子邮件应用程序设计中显示不同颜色的新电子邮件


how to show new email with different color in my email application design using laravel

我创建了一个系统,在其中我获取收件箱并将其显示在一个页面上。新收到的电子邮件自动排在第一位。但现在我必须显示一个标记或不同的颜色,告诉用户这是新邮件。如何使用laravel 5来完成此操作。

这是我的控制器方法:

    public function getMail()
{
    /* connect to gmail */
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = 'xyz@gmail.com';
    $password = 'xyz';
    /*Get all the data in $inbox*/
    $inbox = imap_open($hostname, $username, $password) or die('Cannot connect: ' . imap_last_error());
    /*collect ALL the messages in inbox*/
    $emails = imap_search($inbox, 'ALL');
    /*Collect unread messages only*/
    $emails_unread = imap_search($inbox, 'UNSEEN');
    /*Count rows from table 'Email'*/
    $row_count = count(Email::all());
    $email_count = count($emails);
    $emails_unread_count = count($emails_unread);
    /*For the first time when a new email is added*/
    if($row_count == 0){
        rsort($emails);
        foreach($emails as $all_email){
            $header = imap_headerinfo($inbox,$all_email);
            $message = quoted_printable_decode (imap_fetchbody($inbox, $all_email, 1));
            $from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
            $toaddress = $header->toaddress;
            $message_number =  $header->Msgno;
            Email::create(['from'=>$from, 'body'=>$message , 'message_no'=>$message_number]);
        }
        return $this->show();
    }
    /*when a new email gets added, compare stored email numbers with new email count */
    elseif($row_count < $email_count){
        rsort($emails_unread);
        foreach($emails_unread as $unread){
            $header = imap_headerinfo($inbox, $unread);
            $message = quoted_printable_decode (imap_fetchbody($inbox, $unread, 1));
            $from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
            $toaddress = $header->toaddress;
            $message_number =  $header->Msgno;
            Email::create(['from'=>$from, 'body'=>$message , 'message_no'=>$message_number]);
        }
        return $this->show();
    }
    /*IF both above fails*/
    else{
        return $this->show();
    }
    imap_close($inbox);
}
  1. 在Laravel中创建视图以显示此数据Laravel-视图

  2. 将css文件添加到此视图中,并为看不见的电子邮件指定类

  3. 显示不可见邮件的彩色背景数据