我正在使用CodeIgniter电子邮件库发送带有文件附件的电子邮件。但是,除了电子邮件正文外,一切都工作正常,邮箱中显示的是Html源代码。请帮助解决这个问题。
下面是控制器页面
$this->load->library('upload');
$config = array(
'protocol' => 'sendmail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxxxxxxxx',
'smtp_pass' => 'xxxxxxxxxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE,
'priority' => '1'
);
$data['message']=$message;
// Upload file
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($sendermail, $sendername);
$this->email->to($receivermail);
$this->email->subject($subject);
$this->email->message($this->load->view('email',$data,true));
$filename=null;
if (!empty($_FILES['attachment']['name']))
{
$files = $_FILES['attachment'];
$config_data['upload_path'] = 'uploads/';
$config_data['allowed_types'] = 'jpg|jpeg|png';
$_FILES['attachment']['name'] = time().'_'.$files['name'];
$filename=$_FILES['attachment']['name'];
$_FILES['attachment']['type'] = $files['type'];
$_FILES['attachment']['tmp_name'] = $files['tmp_name'];
$_FILES['attachment']['error'] = $files['error'];
$_FILES['attachment']['size'] = $files['size'];
$this->upload->initialize($config_data);
if ($this->upload->do_upload('attachment'))
{
$upload_data = $this->upload->data();
$this->email->attach($upload_data['full_path']);
}
}
// Upload file
$this->email->send();
enter code here
下面是查看页面email.php ----------------------
<html>
<head>
</head>
<body>
<?php echo $message;?>
</body>
</html>
1条答案
按热度按时间plupiseo1#
您需要将内容配置为HTML
或