当我使用codignator电子邮件类发送电子邮件时显示html源的电子邮件 [英] Email showing html source when i send email using codignator email class

查看:184
本文介绍了当我使用codignator电子邮件类发送电子邮件时显示html源的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题使用codeignitor电子邮件类的邮件显示html代码而不是html视图。

I have a problem in sending html mail with attachment in codeignitor using codeignitor email class the mail showing html code instead of html view.

我已经设置mailtype为html in config below is my code

i had set the mailtype as html in config below is my code

$message="<p>test</p>";
$mail_to = "email@gmail.com";
$from_mail = $useremail;
$from_name = $userfname;
$reply_to = $useremail;
$subject = "Abstract Details";



$file_name = $datamail['varafile'];
$path = realpath('uploads/abstract');

// Read the file content
$file = $path.'/'.$file_name;

$config = array (
              'protocol' =>'sendmail',
                          'mailtype' => 'html',
                          'charset'  => 'utf-8',
                          'priority' => '1'
                               );
       $this->load->library('email',$config);


      $this->email->set_newline("\r\n");

       $this->email->from($from_mail,$from_name);
        $this->email->to($mail_to);    
        $this->email->subject($subject);      
        $this->email->message($message);
        $this->email->attach($file);
        if($this->email->send()){
        echo "Mail send successfully";

        }else{
         echo "Error in sending mail";

        }


推荐答案


以这种方式配置

configure it like this way



$config = Array(
    'protocol' => 'sendmail',
    'mailtype' => 'html',
    'smtp_host' => '', //your SMTP host
    'smtp_port' => 26,
    'smtp_user' => '', //your SMTP email address
    'smtp_pass' => '', //your SMTP email password
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->set_header('MIME-Version', '1.0; charset=utf-8'); //must add this line
$this->email->set_header('Content-type', 'text/html'); //must add this line

$this->email->from('', ''); //from/sender email [with name (optional)]
$this->email->to(); //to/receiver email

$this->email->subject(''); //email subject
$message = $this->load->view('...directory.../...filename...',$data,TRUE); //html template/body with dynamic data
$this->email->message($message);
$this->email->send();

这篇关于当我使用codignator电子邮件类发送电子邮件时显示html源的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆