我想在codeigniter控制器中发送电子邮件。我在身体中使用了foreach循环来进行多次附着。但它不起作用。给我一些建议 这是我的控制器功能。
function emailSend($ship_item_data{
//$link = base_url();
$email ="abc.develop01@gmail.com";
$this->load->library('email');
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->from($email, 'GHL Sports');
$this->email->to($email);
$this->email->subject('Sold items detail');
$msg='<html>
<head>
<title>Sold item</title>
</head>
<body>
Dear GHL Sports Client.
<p>This items heas been sold.</p><ul>';
foreach($ship_item_data as $data){
$item = $data['image_name'];
$this->email->attach("sold/".$item);
$msg .= '<li>'. $item .'</li>';
}
$msg .='</u>
Please do reply to this email as it will not be monitored.
</body>
</html>';
$this->email->message($msg);
//$link = base_url();
//$this->email->attach("sold/1.jpg");
//Send mail
if($this->email->send()) {
echo "email send successfully";
}else{
echo "email not send";
}
我还在构造函数中包含了电子邮件库。
$this->load->helper('path');
$this->load->library('email');
答案 0 :(得分:0)
您需要使用 $ this-&gt; email-&gt; clear(TRUE); 来清除循环中设置的变量。