2016-10-27 2 views
1

マンドリルを使用してメールを設定しようとしています。私はデータベースからいくつかのブログの内容を取り出してメールに送信しています。データベース列のタイトルと本文フィールドを追加するときにproblem.Elseが整数値で正常に動作しています。 メールの内容::ここでデータベースからフェッチされた文字列型のコンテンツでマンドリルが動作しません

$record .= '<tr> 
        <td colspan="2"> 
         <table width="100%"> 
          <tr> 
           <td style="font-size: 16px; color: rgb(215, 215, 215); padding: 15px 12px 0px;" align="center"> 
           via 
           <a href="'. $Notify->getHref($subject) .'" style="color: rgb(0, 153, 0); font-size: 16px;">'.$Notify->userDisplayName($subject).'</a>(@'.$subject->username.') 
           </td> 
          </tr> 
          <tr> 
           <td> 
            <table width="100%"> 
             <tr> 
              '.$photo.' 
              <td style="padding: '.$padding.' ; vertical-align: top;"> 
               <a href="'.$link.'" style="color:rgb(102, 102, 102); font-size: 24px; font-family: &quot;Impact&quot;">'.$blog->title . '</a> 
               <p style="margin-top:0px;color:rgb(140, 140, 140); font-size: 15px; font-family: &quot;Arial&quot;"> 
               ' . $des .' 
               </p> 
              </td> 
             </tr> 
            </table> 
           </td> 
          </tr> 
         </table> 
        </td> 
       </tr>'; 
Code for mandril :    
        try { 
          $mandrillApiKey = $Notify->getSetting('mandrill.api.key'); 
          $mandrill = new Mandrill($mandrillApiKey); 

          // Getting the Subject of the Mail Template 
          $templateDetails = $mandrill->templates->getList($mandrillTemplateName); 

          $message = array(
           'subject' => $templateDetails['subject'], 
           'from_email' => $templateDetails['from_email'], 
           'to' => array(
            array(
             'email' => '[email protected]', 
             'name' => $Notify->getTitle($user) 
            ) 
           ), 
           'merge_vars' => array(
            array(
             'rcpt' => '[email protected]', 
             'vars' => array (
              array(
               'name' => 'content', 
               'content' => $record, 
              ), 
              array(
               'name' => 'day', 
               'content' => $day, 
              ),           

             ) 
            ) 
           ) 
          ); 

          $template_content = array(); 
          $mandrill->messages->sendTemplate($mandrillTemplateName, $template_content, $message); 
          echo 'mail hasbeen sent'; 

         } catch(Mandrill_Error $e) { 
          //echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage(); 
          // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123' 


          throw $e; 
         } 

を、私はそれが適切なコンテンツを与えている$レコードをエコー場合

これは私がしようとしています何私のコードです。しかし、もし私がmandrillを送信しようとしている場合は、api key errorを投げます。今私が$ blog-> title、$ dscを削除すると、メールが機能しています。しかし、私は自分のメールにブログのタイトルと説明が必要です。 私を助けてください。私はどこからでも解決策や助けを得ていません。あなたの小さな助けが私から大きくなるでしょう。

答えて

0

私のコンテンツにhtmlentities()を追加してこの問題を解決しました。 like htmlentities($blog->title)

関連する問題