2017-02-22 10 views
0

ループ経由で電子メールを送信するときに問題が発生します。私はhtmlとプレーンテキスト形式で別のユーザー名を得ています。電子メールを送信する際のHTMLとプレーンテキストの別の名前

これは、(私のコントローラ 機能レポートです)私は、電子メール、HTML形式をクリックしたときに、{

$this->load->model('Searchmonitoring_db'); 
    $results = $this->Searchmonitoring_db->getLogs(); 

    if (!$results) 
      return false; 

    $this->load->library('email'); 
    $config['mailtype'] = 'html'; 
    $this->email->initialize($config); 

    foreach ($results as $result) { 

     $fname = $result['fname']; 
     $username = $result['username']; 
     $subject_keyword = $result['grpname']; 

     if ($subject_keyword == "") { 

      $findfields['clientid'] = $result['clientid']; 
      $findfields['grouping'] = $result['grouping']; 
      $keywords = $this->Searchmonitoring_db->getKeywords($findfields); 

      if ($keywords['db']) { 
       foreach ($keywords['db'] as $kw) { 
        if ($subject_keyword != "") 
          $subject_keyword .= ", "; 
        $subject_keyword .= $kw['query']; 
       } 
      } 
     } 

     $this->email->clear(TRUE); 

     $managerEmail = $result['manager_email']; 
     $manager = $result['manager']; 
     $salespersonEmail = $result['salesperson_email']; 
     $salesperson = $result['salesperson']; 
     $clientEmail = $result['email']; 

     if($managerEmail) { 
      $this->email->from($managerEmail, $manager); 
     } elseif($salespersonEmail) { 
      $this->email->from($salespersonEmail, $salesperson); 
     } 

     $this->email->to($clientEmail); 


     $arrfname = explode("/", $fname); 
     $subject = "Your $subject_keyword monitoring report"; 
     $this->email->subject($subject); 
     $message = $this->load->view('emailtemplate', $result, true); 
     $this->email->message($message); 
     $this->email->attach("../export/$username/" . end($arrfname) . ".zip"); 

     if ($this->email->send()) { 
      $update['id'] = $result['logid']; 
      $searchlog['result'] = 'Sent'; 
      $this->Searchmonitoring_db->updateLog($update, $searchlog); 
     } 
    } 
} 

これは私の電子メールテンプレート

<html> 
<body> 

<p>Hi <?php echo $firstname; ?></p> 
<p>Thanks for your business!</p> 
<p> 
<?php 
if($manager) { 
    echo nl2br($manager_email_signature); 
} elseif($salesperson) { 
    echo nl2br($salesperson_email_signature); 
} ?> 
</p> 
</body> 
</html> 

である私も、私の電子メールを監視するために消印を使用し、正しい名前を取得しますが、プレーンテキスト形式をクリックしたときにその名前が間違っています。

例: html:「あなたのビジネスのためのハイジャック」と言う。 プレーンテキスト:「あなたのビジネスに感謝します。

私が使用してみてくださいプレーンテキストが

答えて

0

ループで最初の電子メールの名前を取得していることに気づい:

関連する問題