发送的邮件带有 html 标签而不是纯文本
Mail being sent with html tags instead of plain text
我正在通过从视图文件加载电子邮件来发送邮件。
我发送的电子邮件带有 HTML 个标签,如下所示:
<html><body>Hi mom!</body></html>
我希望它在没有标签的情况下以纯文本形式发送:
Hi mom!
查看下面的代码:
public function savepromo(){
$allemail = $this->AdminModel->getallemail();
$data['promos'] = $this->AdminModel->getallpromos();
$totalrows = $this->AdminModel->countemail();
if ($totalrows > 0) {
$limit = 10;
$totalbatches = ceil($totalrows/$limit);
for ($batch = 0; $batch < $totalbatches; $batch++){
$offset = $batch * $limit;
$batch_record = array();
$destination = "";
foreach ($this->AdminModel->fetchrecords($limit,$offset) as $value){
array_push($batch_record,$value->email);
}
$destination = implode(';', $batch_record);
$config = array(
'charset' => 'utf-8',
'wordwrap' => TRUE,
'mailtype'=> 'html'
);
$this->load->initialize($config);
$fromemail="mytestingemail@mail.com";
$toemail = $destination;
$subject = "THIS IS FOR TESTING PURPOSES DONT MIND THIS MESSAGE!";
$mesg = $this->load->view('email/promomessage',$data,TRUE);
$this->load->library('email');
$this->email->from($fromemail, 'MY TESTING EMAIL');
$this->email->to($destination);
$this->email->subject($subject);
$this->email->message($mesg);
$this->email->send();
}
}
$this->session->set_flashdata('try', '<div class="alert alert-danger text-center">SUCCESS!</div>');
redirect('administrator/createpromo');
}
}
你必须告诉CI邮件类型:
$this->email->set_mailtype("html");
或
$config['mailtype'] = 'html';
调用前 $this->email->send()
.
我正在通过从视图文件加载电子邮件来发送邮件。
我发送的电子邮件带有 HTML 个标签,如下所示:
<html><body>Hi mom!</body></html>
我希望它在没有标签的情况下以纯文本形式发送:
Hi mom!
查看下面的代码:
public function savepromo(){
$allemail = $this->AdminModel->getallemail();
$data['promos'] = $this->AdminModel->getallpromos();
$totalrows = $this->AdminModel->countemail();
if ($totalrows > 0) {
$limit = 10;
$totalbatches = ceil($totalrows/$limit);
for ($batch = 0; $batch < $totalbatches; $batch++){
$offset = $batch * $limit;
$batch_record = array();
$destination = "";
foreach ($this->AdminModel->fetchrecords($limit,$offset) as $value){
array_push($batch_record,$value->email);
}
$destination = implode(';', $batch_record);
$config = array(
'charset' => 'utf-8',
'wordwrap' => TRUE,
'mailtype'=> 'html'
);
$this->load->initialize($config);
$fromemail="mytestingemail@mail.com";
$toemail = $destination;
$subject = "THIS IS FOR TESTING PURPOSES DONT MIND THIS MESSAGE!";
$mesg = $this->load->view('email/promomessage',$data,TRUE);
$this->load->library('email');
$this->email->from($fromemail, 'MY TESTING EMAIL');
$this->email->to($destination);
$this->email->subject($subject);
$this->email->message($mesg);
$this->email->send();
}
}
$this->session->set_flashdata('try', '<div class="alert alert-danger text-center">SUCCESS!</div>');
redirect('administrator/createpromo');
}
}
你必须告诉CI邮件类型:
$this->email->set_mailtype("html");
或
$config['mailtype'] = 'html';
调用前 $this->email->send()
.