如何从电子邮件表单中删除标签和字符实体

时间:2016-01-09 14:58:38

标签: php email textarea

我正在创建一个电子邮件表单,并发送了以下测试消息:

<p>test</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>test test</p>

但是,我收到了以下包含标签和字符实体的邮件:

function sendemail(){

$this->load->helper('file');
if ($this->input->post('subject')){
    $test = $this->input->post('test');
    $subject = $this->input->post('subject');
    $msg = $this->input->post('message');

        $this->email->clear();
        $this->email->from('extample@example.com', 'sender');
        $this->email->to('example@example.com');
        $this->email->subject($subject);
        $this->email->message($msg);        
        $this->email->send();
        $this->session->set_flashdata('message', "test mail sent");
        write_file('/tmp/email.log', $subject ."|||".$msg);
        redirect('admin/subscribers/sendemail','refresh');
    }

这是处理邮件的PHP代码:

echo form_open('admin/subscribers/sendemail');

echo "<p><label for='subject'>Subject</label><br/>";

$data = array('name' => 'subject', 'id' => 'subject', 'size' => 50, 'value'=>$subject);

echo form_input($data);

echo "</p>";


echo "<p><label for='message'>Message</label><br/>";

$data = array('name' => 'message', 'id' => 'message', 'rows' => 20, 'cols' => 50, 'value'=>$msg);

echo form_textarea($data);

echo "</p>";


echo "<p>".form_checkbox('test', 'true', TRUE) . " <b>This is a test!</b></p>";

echo form_submit('submit','Sent email');

echo form_close();

?>

这是邮件表单的php:

str.length

0 个答案:

没有答案