2012-01-19 4 views
0

이메일 본문에 동적으로 HTML 테이블을 생성하지만 전자 메일에서 테이블을 표시하는 대신 HTML 코드가 수신됩니다. 도와주세요. 내 코드는 다음과 같습니다. 내 서버에서이 코드를 지원하는 메일은 $ email_message = "name :".clean_string ($ name). "\ n"; 이 코드를 사용하여 도와주세요.PHP를 사용하여 HTML 표가있는 이메일을 보내는 방법은 무엇입니까?

<?php 
require ('class.phpmailer.php'); 

$name = @$_REQUEST['name']; 
//$email = @$_REQUEST['email']; 
$contact = @$_REQUEST['contact']; 
$day = @$_REQUEST['day']; 
$month = @$_REQUEST['month']; 
$year = @$_REQUEST['year']; 
$date_event = @$_REQUEST['date_event']; 
$check = @$_REQUEST['check']; 
$check_score = @$_REQUEST['check_score']; 
$check_service = @$_REQUEST['check_service']; 
$check_product = @$_REQUEST['check_product']; 
$check_scheme = @$_REQUEST['check_scheme']; 
$check_value = @$_REQUEST['check_value']; 
$check_price = @$_REQUEST['check_price']; 



$arr = array($year,$month,$day); 
$doe_event = join("-",$arr); 

[email protected]$_REQUEST['action']; 

$today=getdate(); 
$gday="$today[mday]"; 
$gmonth="$today[mon]"; 
$gyear="$today[year]"; 
$ghour="$today[hours]"; 
$gminutes="$today[minutes]"; 
$gsecond="$today[seconds]"; 
$create_date="$gyear-$gmonth-$gday $ghour:$gminutes:$gsecond"; 

if($action=='add') { 

     $email_to = "your email"; 
     $email_subject = "Message From Website"; 

     $error_message = ""; 
     $email_exp = "^[a-z .'-]+$"; 
     $email_message = "<strong>Contact form</strong><br>"; 

     function clean_string($string) { 
      $bad = array("content-type","bcc:","to:","cc:","href"); 
      return str_replace($bad,"",$string); 
     } 

      //All data In table mail 
      $headers = "From: $ContactPerson<[email protected]*******.co.in> \n"; 
      $headers .= "Reply-To: $to \r\n"; 
      $headers .= "X-Mailer: PHP/". phpversion(); 
      $headers .= "X-Priority: 3 \n"; 
      $headers .= "MIME-version: 1.0\n"; 
      $headers .= "Content-Type: text/html; charset=UTF-8\n";     
$email_message='<table cellspacing="0" cellpadding="0" border="1" align="center"> 
       <tr> 
        <td bgcolor="#99CC00">Name &nbsp;'; 
         $email_message = "Quick enquiry detail."; 
       $email_message = " ".clean_string($name)."\n";'</td> 
       </tr> 
       </table>'; 


      //$email_message .= clean_string($email);    
      //$email_message = "Quick enquiry detail."; 
      $email_message .= "name: ".clean_string($name)."\n"; 
      $email_message .= "contact: ".clean_string($contact)."\n"; 
      $email_message .= "doe: ".clean_string($doe_event)."\n"; 

    if(isset($_REQUEST['check']) && count($_REQUEST['check'])) 
      { 

       $recipient_email_addresses = array 
       (
); 
        foreach($_REQUEST['check'] as $value){ 
       $email_message .= "services: ".clean_string($value)."\n"; 
       }; 

    }    

      // create email headers 
      $email_from="[email protected]*******.co.in"; 

      $headers = 'From: '.$email_from."\r\n". 
      'Reply-To: '.$_REQUEST['email']."\r\n" . 
      'X-Mailer: PHP/' . phpversion(); 
      $mail = new PHPMailer(); 
      $mail->IsSMTP(); 
      $mail->FromName = $_REQUEST['name']; 
      $mail->Host = 'mail.*******.co.in'; 
      $mail->SMTPAuth = true; 
      $mail->Username = '[email protected]********.co.in'; 
      $mail->Password = '********'; 

      $mail->AddAddress("your email", "ADMIN"); 


      $mail->Subject = "Contact Enquiry From www.********.co.in"; 
      $mail->Body = $email_message; 

      if($mail->Send()) 
      { 

    echo "<script>alert('Thank you for quick submit.') </script>"; 
    echo "<script>location.replace('index.php?action=msgsent');</script>";     
       die; 
      } 
      else 
      { 
    echo "<script>alert('There was an error sending the message, Please try again.')</script>"; 
       echo "<script>location.replace('index.php?action=msgerr');</script>";     
       die;      
      } 

    } 

>

+3

[PHP에서 이메일 본문에 html 테이블을 보내는 방법은?] (http://stackoverflow.com/questions/6160320/how-to-send-html-table-in-email-body- in-php), 처음 세 문장까지. – outis

+0

친애하는 하나님이 얼마나 혼란 스럽습니까 ... – veritas

+0

위의 코드에서 생성되는 HTML이 실제로 무엇인지 확인 했습니까? 나는 ... w3schools에 대해 – DaveRandom

답변

3

PHPMailer 들어있다 :

 

$mail->IsHTML(true); //try adding this 
 

참조 : Html Mails

-1

w3schools.com을 참조하십시오. 예를 들어 적절한 아이디어를 찾을 수 있습니다. 시도해보기

+2

-1을 의심합니다. http://w3fools.com/ – DaveRandom

+0

@daveRandom - 나쁜 suggesion 아니 었어 –

+0

@DaveRandom - 허 ... –

관련 문제