Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

email - send html mail using codeigniter

Error in mail content using SMTP in codeigniter Actually, my mail is sent with HTML tags and it is showing the HTML tags which is not correct.

$config = Array(
'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => '[email protected]',
        'smtp_pass' => '',
        'mailtype'  => 'html', 
        'charset' => 'utf-8',
        'wordwrap' => TRUE

    );
    $this->load->library('email', $config);
    $this->email->set_newline("
");
    $email_body ="<div>hello world</div>";
    $this->email->from('[email protected]', 'ddd');

    $list = array('[email protected]');
    $this->email->to($list);
    $this->email->subject('Testing Email');
    $this->email->message($email_body);

    $this->email->send();
    echo $this->email->print_debugger();

If am sending mail without using SMTP it works fine. What is my mistake?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can try this line of code which will set the mail type to be for HTML:

 $this->email->set_mailtype("html");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...