Php 将html模板发送到电子邮件的表单

Php 将html模板发送到电子邮件的表单,php,html,codeigniter,Php,Html,Codeigniter,表单内容已发送到我的电子邮件,但电子邮件中无法识别HTML和CSS代码。仅输出纯文本 下面是我的控制器 public function registration() { $email = $this->input->post('email'); $domain = $this->input->post('domain_name'); $passw = $this->input->post('passw'); $name = $

表单内容已发送到我的电子邮件,但电子邮件中无法识别HTML和CSS代码。仅输出纯文本

下面是我的控制器

public function registration() {

    $email = $this->input->post('email');
    $domain = $this->input->post('domain_name');
    $passw = $this->input->post('passw');
    $name = $this->input->post('name');
    $skype = $this->input->post('skype');
    //  $package = $this->input->post('package');

    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'xxxx.com',
        'smtp_port' => 25,
        'smtp_user' => 'xxx@xxxxxx.com',
        'smtp_pass' => 'xxxxx',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1'
    );

    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from('xxx@xxxxxx.com', 'welcome');
    $this->email->to('xxxxx@xxxxxxxx.com');

    $this->email->subject('registration');

    $body = $this->load->view('dns/template', TRUE);


    $this->email->message($body, TRUE);

    $this->email->send();

    $data['message'] = 'Submitted Sucessfullly';
    $data['emails'] = $this->Dns_model->emails($domain);

    $this->load->view('dns/sucessful', $data);
}
下面是我保存为template.php的视图

我的视图(模板)


登记

我希望您没有使用用于电子邮件模板的解析器库,所以考虑到上述条件,下面是我的答案

  • 你的模板有问题,这意味着你在那里写的Html代码,它们有不匹配的标记或者一些标记用在了错误的地方。所以你必须先检查一下

  • 如果您仍然无法找到问题,那么您只需使用下面的代码创建一个模板,您将看到邮件不再是普通文本

    很好,你搞定了
  • 注意:不要使用或etc标记,也要使用
    而不是


    电子邮件模板在哪里?尝试html电子邮件什么是错误或输出??谢谢@xpuc7o我已经更新并添加了我的模板,@Abdulla没有收到任何错误,只是出现了纯文本,电子邮件中没有css尝试使用内联css创建模板,所有代码都应该放在表标记中。
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <html> <!--<![endif]-->
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Registration</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="<?php echo base_url()?>/assets/bootstrap/css/bootstrap.min.css">
      <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap.css">
      <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/bootstrap-responsive.min.css">
       <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/font-awesome.min.css">
        <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/main.css">
        <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/style.css">
        <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/AdminLTE.css">
        <link rel="stylesheet" href="<?php echo base_url()?>/assets/css/sl-slide.css">
    
        <script src="<?php echo base_url()?>/assets/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <script src='https://www.google.com/recaptcha/api.js'></script>
    
        <!-- Le fav and touch icons -->
        <link rel="shortcut icon" href="<?php echo base_url()?>/images/ico/favicon.ico">
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo base_url()?>/images/ico/apple-touch-icon-144-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo base_url()?>/images/ico/apple-touch-icon-114-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="i<?php echo base_url()?>/mages/ico/apple-touch-icon-72-precomposed.png">
        <link rel="apple-touch-icon-precomposed" href="<?php echo base_url()?>/images/ico/apple-touch-icon-57-precomposed.png">
    
     </head>
    
    <body id="con"  onLoad="generate();">
    <div id="fb-root"></div>
    <div class="container">
    <section class="main-info">
    <br>
    <section id="recent-works3">
    
    <section id="pricing-table">
    
    
        <div class="row-fluid center clearfix">
    
    
    
            <div class="span3">
    
            </div>
    
    
    
            <div class="span6">
     <ul class="plan plan3">
                        <li class="plan-name">             
                            <span class="lead3">Emails to be setup</span>
                        </li>
      </ul>
      <table class="table">
        <thead>
        <tr>
         <th>Email</th>
         <th>Password</th>
         </tr>
        </thead>
        <tbody>
         <tr class="info">
         <td>info@test.com</td>
         <td>terfwws6w</td>
          </tr>
        </tbody>
        </table>
        <ul class="plan plan3">
          <li class="plan-action">
           <a href="http://www.xxxxxx.com" class="btn btn-transparent">Registration website</a>
             </li>
                </ul>
            </div>
    
            <div class="span3">
    
    
            </div>
        </div>
    </section>
    </section>
    </section>
    </div>
    </div>                       
     <script src="<?php echo base_url()?>/assets/js/vendor/jquery-1.9.1.min.js">     </script>
     <script src="<?php echo base_url()?>/assets/js/vendor/bootstrap.min.js"></script>
     <script src="<?php echo base_url()?>/assets/js/main.js"></script>
    <script src="<?php echo base_url()?>/assets/js/jquery.ba-cond.min.js"></script>
       </body>
       </html>