2012-03-04 87 views
-1

我想收到以下電子郵件雷鳥但到達空白。發件人和主題*是完整的,但該消息尚未空白的print_debugger();顯示的所有內容**等笨:HTML電子郵件到達空白

*主題顯示了公司名稱,但不是「用戶註冊確認」文本

**我也越來越以下錯誤print_debugger();頁面上,但我認爲它是由print_debugger();

Message: Cannot modify header information - headers already sent by line 72 -> echo $this->email->print_debugger(); for both the session and url_helper

配置造成的:

$config['protocol'] = 'mail'; 
$config['wordwrap'] = FALSE; 
$config['send_multipart'] = FALSE ; 
$config['mailtype'] = 'html'; 

控制器:

function _userRegEmail($activateCode,$email,$firstname,$lastname){ 
     $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName; 
     $data['companyEmail'] = $this->core_model->companyDetails()->coreContactEmail; 
     $data['companyContact'] = $this->core_model->companyDetails()->coreContactName; 
     $data['firstName'] = $firstname; 
     $data['lastName'] = $lastname; 
     $data['email'] = $email; 
     $data['activateCode'] = $activateCode; 

     $this->email->from($this->core_model->companyDetails()->coreContactEmail, $this->core_model->companyDetails()->coreCompanyName); 
     $this->email->to($email); 
     $this->email->subject($this->core_model->companyDetails()->coreCompanyName 'User Registration Confirmation'); 

     $messageContent= $this->load->view('email_templates/userReg',$data, TRUE); 

     $this->email->message($messageContent); 

     $this->email->send(); 

     echo $this->email->print_debugger(); 
    } 

查看:

<html> 
    <head> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> 
    <title/> 
    </head> 
    <body> 
    <div class="container" style="width: 600px;height: 100%;margin: 0 auto;font-family: Arial, &quot;MS Trebuchet&quot;, sans-serif"> 
     <div class="header" style="width: 100%"> 
      <h1 style="text-align: center;color: #00afd8"><?php echo $companyName; ?></h1> 
      </div> 
       <div class="content"> 
        <h2 style="font-size: 15px">Hello <?php echo $firstName; ?></h2> 
       <p style="margin-left: 15px">Thank you for signing up to Farm Ads.</p> 
       <p style="margin-left: 15px">Could you please click <a href="<?php base_url(); ?>users/confirm/"<?php $activateCode; ?>>here</a> to activate your account.</p> 

       <div class="from"> 
        <p class="bold" style="margin-left: 15px;font-weight: bold;font-size: 12px">Regards,</p> 
        <p style="margin-left: 15px;font-weight: bold;font-size: 12px"><?php $companyContact; ?></p> 
        </div> 
      </div> 
     </div> 

</body> 
</html> 

回答

2

你不及格$data到視圖。相反的:

$messageContent= $this->load->view('email_templates/userReg','', TRUE); 

試試這個:

$messageContent= $this->load->view('email_templates/userReg', $data, TRUE); 

在該電子郵件主題行,你忘了.兩個字符串連接代碼:

$this->email->subject($this->core_model->companyDetails()->coreCompanyName.' User Registration Confirmation'); 

還有一個錯誤在你看來。 $activateCode應該在<a href="">的引號內,而不是在外面。你在視圖中的幾個地方忘了echo

<a href="<?php echo base_url(); ?>users/confirm/<?php echo $activateCode; ?>">here</a> 
+0

opps,我需要更新代碼,是從以前的問題。我現在通過$ data – 2012-03-04 02:46:37

+0

當你解決我指出的其他錯誤時,它是否工作? – Mischa 2012-03-04 02:50:58

+0

沒有尚屬空白主題現在正在甜蜜 – 2012-03-04 03:23:19