Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 使用codignator Email类发送电子邮件时显示html源的电子邮件_Codeigniter_Email - Fatal编程技术网

Codeigniter 使用codignator Email类发送电子邮件时显示html源的电子邮件

Codeigniter 使用codignator Email类发送电子邮件时显示html源的电子邮件,codeigniter,email,Codeigniter,Email,我在使用codeignitor电子邮件类发送带有附件的html邮件时遇到问题。该邮件显示html代码而不是html视图 我在下面的代码配置中将邮件类型设置为html $message="<p>test</p>"; $mail_to = "email@gmail.com"; $from_mail = $useremail; $from_name = $userfname; $reply_to = $useremail; $subject = "Abstract Detail

我在使用codeignitor电子邮件类发送带有附件的html邮件时遇到问题。该邮件显示html代码而不是html视图

我在下面的代码配置中将邮件类型设置为html

$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";

        }
$message=“测试”

”; $mail_to=”email@gmail.com"; $from_mail=$useremail; $from_name=$userfname; $reply_to=$useremail; $subject=“抽象细节”; $file_name=$datamail['varafile']; $path=realpath('uploads/abstract'); //读取文件内容 $file=$path.'/'.$file\u name; $config=array( '协议'=>'发送邮件', “邮件类型”=>“html”, “字符集”=>“utf-8”, “优先级”=>“1” ); $this->load->library('email',$config); $this->email->set_newline(“\r\n”); $this->email->from($from\u mail,$from\u name); $this->email->to($mail\u to); $this->email->subject($subject); $this->email->message($message); $this->email->attach($file); 如果($this->email->send()){ 回显“邮件发送成功”; }否则{ 回显“发送邮件时出错”; }
[向所有人道歉,我没有足够的代表评论澄清]

我刚刚尝试了你的确切代码(减去附件位),通过向Gmail帐户发送HTML电子邮件,一切都很好,我将在下面提供我的完整工作课程:

class rohithipix extends CI_Controller {

    public function html_email() {

        $message = "<h1>start</h1><p>test</p>";
        $mail_to = "test@gmail.com";
        $from_mail = 'test2@gmail.com';
        $from_name = 'dave';
        $reply_to = 'test2@gmail.com';
        $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";
        }
    }

}
class Rohitipix扩展CI_控制器{
公共功能html_电子邮件(){
$message=“开始测试”

”; $mail_to=”test@gmail.com"; $from_mail='10〕test2@gmail.com'; $from_name='dave'; $回复test2@gmail.com'; $subject=“抽象细节”; //$file_name=$datamail['varafile']; //$path=realpath('uploads/abstract'); //读取文件内容 //$file=$path.'/'.$file\u name; $config=array( '协议'=>'发送邮件', “邮件类型”=>“html”, “字符集”=>“utf-8”, “优先级”=>“1” ); $this->load->library('email',$config); $this->email->set_newline(“\r\n”); $this->email->from($from\u mail,$from\u name); $this->email->to($mail\u to); $this->email->subject($subject); $this->email->message($message); //$this->email->attach($file); 如果($this->email->send()){ 回显“邮件发送成功”; }否则{ 回显“发送邮件时出错”; } } }
测试时,您试图将这些邮件发送到哪个电子邮件客户端

这样配置它


@Adam Westbrook回答了你的问题吗?因为你应该承认。或者如果你发现了,你应该发布你的解决方案。只是说,这就是它的工作原理。$this->email->set_头('MIME-Version','1.0;charset=utf-8')$此->电子邮件->设置标题('Content-type','text/html');以上两行对我有用:)
$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();