2017-12-19 9 views
-1

PHP 스크립트를 사용하여 이메일을 보내려고합니다. 성공했습니다. 일반 텍스트 대신 CSS 디자인과 표식 데이터가 포함 된 HTML 템플릿을 보내고 싶지만 일반 텍스트를 얻고 있습니다. 여기 코드는 다음과 같습니다PHP 웹 메일을 사용하여 html 템플릿으로 이메일을 보내는 방법

$headers='Content-Type: text/html; charset="UTF-8"'; 
         $from = 'UCVOGUE'; 
         $subject = 'Order Confirmation from UCVOGUE'; 
         $message = '<html> 
         <body> 
         <div class="col-md-12 email-box"> 
      <div class="row"> 
      <div class="col-md-2"> 
       <img src="images/clogo.png" width="50%" class="center-block"> 
      </div> 
      <div class="col-md-8"> 
       <center><h2>Greetings from Ucvogue</h2></center> 
      </div> 
      <div class="col-md-2"> 
       <center><h3>Order No:12501468</h3></center> 
      </div> 
      </div><hr> 
     </div> 
     <div class="row"> 
      <div class="col-md-12"> 
       <table class="table table-bordered"> 
       <thead> 
        <tr> 
        <td>Custome:name</td> 
        <td>Product</td> 
        <td>Cost</td> 
        <td>Units</td> 
        <td>Total Cost</td> 
        <td>Address:</td> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
        <td><?php echo $o_cu_name;?></td> 
        <td><?php echo $o_pro_name;?></td> 
        <td><?php echo $o_pro_cost;?></td> 
        <td><?php echo $o_qty;?></td> 
        <td><?php echo $o_cost;?></td> 
        <td><?php echo $o_cu_address;?></td> 
        </tr> 
       </tbody> 
       </table> 
      </div> 
      </div> 
      </body> 
      </html> 
      '; 
         mail($to,$subject,$message,$headers); 

참조 내가이 $ 헤더 변수를 사용하는 대신 부트 스트랩 HTML 템플릿 모델의 일반 텍스트를

+2

부트 스트랩이 함께 따라하지 않을 수 있습니다 당신은 자신이 스타일을 추가해야합니다. 'template.html'을 만들고 php 파일에서'$ message = file_get_contents (template.html)'을 사용하십시오. 이게 작동하면 시도하십시오 – chandlerbing

+0

MIME 및/또는 FROM 헤더가 필요하다고 생각합니다. https://stackoverflow.com/questions/27884043/php-email-not-sending-as-html-why?rq=1 – DragonYen

+0

https ://www.w3schools.com/php/func_mail_mail.asp 예 3을 확인하십시오. –

답변

0

시도를 얻고 방법 첨부 된 스크린 샷 :

$headers[] = 'MIME-Version: 1.0'; 
$headers[] = 'Content-type: text/html; charset=iso-8859-1'; 

다음 변경을 메일 기능을

mail($to,$subject,$message, implode("\r\n", $headers)); 

source

(사용 ISO-8859-1 그것은 가장 인기있는 8 비트 문자 세트에 대한 기초로)