我正试图在我的网站上呈现电子邮件。问题是这些电子邮件包含html和css,这意味着我突然可以在页面上获得绿色背景。它没有正确呈现邮件。有时候我会看到html标签等等。(见下面链接中的图片)
我讨厌iframe。但是你可以看到我在iframe src参数中没有链接参考。
这是使用(MVC)
的代码的一部分这是使用
的模型功能function get_mail_num($email_number)
{
$connection = imap_open($this->server, $this->user, $this->password);
$mail['overview'] = imap_fetch_overview($connection,$email_number,0);
$mail['message'] = imap_fetchbody($connection,$email_number,2);
imap_close($connection);
return $mail;
}
这是控制器功能,它将邮件命名并将其发送到视图
function index() // the inbox
{
$this->load->model('mail_model');
$this->load->library('pagination');
$this->load->library('table');
// config for table
$config['total_rows'] = $this->mail_model->get_size();
$config['per_page'] = 10;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$config['base_url'] = 'http://nullpointer.se/mailendar/mail/index';
$config['num_links'] = 4;
if(!$this->uri->segment(3)){$offset = 1;}else{$offset = $this->uri->segment(3);}
$records = $this->mail_model->get_mail_header($config['per_page'],$offset);
$data['output'] ="";
$id = $offset;
for($i = 0; $i < count($records);$i++)
{
if(empty($records[$i]->subject))
{
$records[$i]->subject = "No Subject";
}
$data['output'].= '<div onclick="funct('.$id.')" class="toggler '.($records[$i]->seen ? 'read' : 'unread').'">';
$data['output'].= '<span class="subject">'.$records[$i]->subject.'</span> ';
$data['output'].= '<span class="from">'.$records[$i]->from.'</span>';
$data['output'].= '<span class="date">on '.$records[$i]->date.'</span>';
$data['output'].= '</div>';
$data['output'].= "<div class='body' id ='{$id}'> </div>";
$id++;
}
$this->pagination->initialize($config);
$data['page'] = "pages/mail";
$this->load->view('includes/template',$data);
}
这是显示所有内容的视图
<div id="main" class="span-19 last colborder">
<h2>Mail</h2>
<?php echo $output//$this->table->generate(); ?>
<?php echo $this->pagination->create_links(); ?>
</div>
<div id = "sidebar" class = "span-4 last">
<h2>Options</h2>
<a href = "Convert" class ="button">Convert</a>
<a href = "Remove" class ="button">Remove</a>
<a href = "Move" class ="button">Move</a>
</div>
答案 0 :(得分:1)
您可能提到了最简单的解决方案。你可以简单地为电子邮件ID 123创建一个简单的电子邮件查看器,例如:viewer.php?id = 123,然后通过简单的iframe显示查看器:
<iframe width="[YOUR_WIDTH]" HEIGHT="[YOUR_HEIGHT]" src="viewer.php?id=123"></iframe>
您在观看者中需要做的就是从模型中获取电子邮件正文,然后回复它。