如果我在自己的库中使用下面的方法编写代码,则它将成功发送电子邮件,但附件未在电子邮件中显示,即附件未随电子邮件附加,同样在启用密件抄送时,它会引发内部服务器错误,但是如果我使用相同的代码在我的控制器中正常工作。
public function sendEmail($arrData=array()){
if($arrData['TO_EMAIL']=='') return FALSE;
$status = FALSE;
$config = array(
'protocol' => 'sendmail',
'charset' => 'utf-8',
'wordwrap' => TRUE,
'mailtype' => 'html'
);
$to = 'ra@gmail.com';
$cci =& get_instance();
$cci->load->library('email', $config);
$cci->email->from($arrData['FROM_EMAIL'], $arrData['FROM_NAME']);
$cci->email->to($arrData['TO_EMAIL'], $arrData['TO_NAME']);
if($arrData['CC_EMAIL'])
$cci->email->cc($arrData['CC_EMAIL']);
//$this->email->bcc('ravr@rediffmail.com');
$cci->email->subject($arrData['SUBJECT']);
$cci->email->message($arrData['MESSAGE']);
if($arrData['FILES'])
$cci->email->attach($arrData['FILES']);
$status = $cci->email->send();
return $status;
}
答案 0 :(得分:0)
使用路径助手
$this->load->helper('path');
$path = set_realpath('pathtouploads'); //your uploads folder
然后
$this->email->attach($path . $file);