html格式的电子邮件在codeigniter中 [英] html formatted emailing in codeigniter

查看:88
本文介绍了html格式的电子邮件在codeigniter中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在codeigniter中发送html格式的电子邮件,我有此代码可以很好地发送电子邮件,但未按其格式进行格式化!您可以看到显示收到电子邮件的图片

how to send html formatted email in codeigniter i have this code which is sending email fine but it is not formatting it as it should look! you can see the picture which displays email received

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

You can try this line of code, which will set mail type to HTML:

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

这篇关于html格式的电子邮件在codeigniter中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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