Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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
Php codeigniter中的html格式电子邮件_Php_Codeigniter_Codeigniter 2_Codeigniter 3_Html Formatting - Fatal编程技术网

Php codeigniter中的html格式电子邮件

Php codeigniter中的html格式电子邮件,php,codeigniter,codeigniter-2,codeigniter-3,html-formatting,Php,Codeigniter,Codeigniter 2,Codeigniter 3,Html Formatting,如何发送html格式的电子邮件在codeigniter我有这个代码,这是发送电子邮件的罚款,但它不是格式化它应该看!您可以看到显示收到的电子邮件的图片 function email_sender() { // $this->load->helper('form'); // $this->load->helper('url'); $config = Array(

如何发送html格式的电子邮件在codeigniter我有这个代码,这是发送电子邮件的罚款,但它不是格式化它应该看!您可以看到显示收到的电子邮件的图片

function email_sender()
        {
            //      $this->load->helper('form');
            // $this->load->helper('url');
            $config = Array(
                    'protocol' => 'sendmail',
                    'smtp_host' => 'ssl://smtp.gmail.com',
                    'smtp_port' => '465',
                    'smtp_timeout' => '7',
                    'smtp_user' => '****@****.com',
                    'smtp_pass' => '*******',
                    'charset' =>'utf-8',
                    'newline' => "\r\n",
                    'MIME-Version' => '1.0',
                    'mailtype' => 'html',
                    'header' => 'MIME-Version: 1.0',
                    'header' => 'Content-type:text/html;charset=UTF-8'
                );//initializing mail headers and information
            if ($this->input->post('submit')==true) 
            {
            $data['name']=$this->input->post('contact-name');
            $data['email']=$this->input->post('contact-email');
            $data['phone']=$this->input->post('contact-tel');
            $data['country']=$this->input->post('contact-country');
            $data['message']=$this->input->post('exampleTextarea');
            }//input from form
            $html_formattedEmail = $this->load->view('includes/email_template', $data, TRUE);//variable that loads view and save it as string
            $this->load->library('email', $config);
            // $this->email-> set_newline("\r\n");
            $this->email->from('abc@abc.com');
            $this->email->to($data['email']);
            $this->email->subject('Contact form submitted');
            $this->email->message($html_formattedEmail);

            if($this->email->send()){
                $data['main_content'] = 'thankyou_page';
                 $data['meta_title'] = 'abc';
                    $data['meta_description'] = 'abc2';
                     $data['meta_author'] = 'abc3';
            $this->load->view('includes/template', $data);

            }
            else{
                show_error($this->email->print_debugger());
            }
        }

将其添加到邮件配置中并重新检查


将其添加到邮件配置中并重新检查。

您可以尝试这行代码,它将邮件类型设置为
HTML

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

您可以尝试这行代码,它将邮件类型设置为
HTML

$this->email->set_mailtype("html");
试试这个

// load email library
$this->load->library('email');
//准备电子邮件

$this->email
    ->from('ex@example.com', 'Example Test.')
    ->to('toex@example.com')
    ->subject('Hello Sample Test.')
    ->message('Hello, We are <strong>Htl content</strong>')
    ->set_mailtype('html');

// send email
$this->email->send();
试试这个

// load email library
$this->load->library('email');
//准备电子邮件

$this->email
    ->from('ex@example.com', 'Example Test.')
    ->to('toex@example.com')
    ->subject('Hello Sample Test.')
    ->message('Hello, We are <strong>Htl content</strong>')
    ->set_mailtype('html');

// send email
$this->email->send();
在代码点火器4.1.1中

这应该是可行的,但完全被忽略了:

$email_config = [
  'mailType' => 'html'
];
$email->initialize($config);
因此,在中加载Altmessage后,可以使用此完全未记录的函数:

$email->setMailType("html");
然后像平常一样加载html版本的消息-如果没有本页提供的其他答案,我无法猜到这一点。

在CodeIgniter 4.1.1中

这应该是可行的,但完全被忽略了:

$email_config = [
  'mailType' => 'html'
];
$email->initialize($config);
因此,在中加载Altmessage后,可以使用此完全未记录的函数:

$email->setMailType("html");

然后像平常一样加载html版本的消息-如果没有本页提供的其他答案,我无法猜到这一点。

您是否在Codeigniter Bilal中使用了PHPMailer?不,不是在Codeigniter中,而是在定制php中使用了php mailer!你在Codeigniter Bilal中使用过PHPMailer吗?没有,不是在Codeigniter中,而是在定制php中使用过PHPMailer!我已经添加了它,但是它不起作用,但是在添加了set_mailtype(“html”)之后,它现在可以正常工作了。很高兴听到这个问题以这样或那样的方式得到了解决。快乐编码!!:)我已经添加了它,但是它不起作用,但是在添加了set_mailtype(“html”)之后,它现在可以正常工作了。很高兴听到这个问题以这样或那样的方式得到了解决。快乐编码!!:)随时准备为CI提供帮助!!随时准备为CI提供帮助!!