2017-08-25 10 views
0

PHPで送信された電子メールをカスタマイズする方法を理解しようとしています。私はその基本となると考えている<html>とテーブル。 $messageエリアで何が間違っていますか?PHPで送信されたHTMLで電子メール本体のフォーマットを作成する方法

私は私のメッセージ領域でこれを取得する今のところ:ここ

<html><body><h1>Hello, World!</h1></body></html> 

は私のコードです:

<?php 
    session_start(); 
    require_once('payflow.php'); 

    $tranid = $_GET['PNREF']; 
    $email = $_GET['EMAIL']; 
    $billtofirstname = $_GET['BILLTOFIRSTNAME']; 
    $billtolastname = $_GET['BILLTOLASTNAME']; 
    $billtoname = $_GET['BILLTONAME']; 
    $billtostreet = $_GET['BILLTOSTREET']; 
    $billtostreet2 = $_GET['BILLTOSTREET2']; 
    $billtocity = $_GET['BILLTOCITY']; 
    $billtostate = $_GET['BILLTOSTATE']; 
    $billtozip = $_GET['BILLTOZIP']; 

    $to = $email; 
    $subject = "ORDER #$tranid\n"; 
    $headers = "From: $email\n"; 

    $message = '<html><body>'; 
    $message .= '<h1>Hello, World!</h1>'; 
    $message .= '</body></html>'; 

    mail($to,$subject,$message,$headers); 

?> 

メール$_GETデータは結構です、うまく動作します。ただ、このドキュメントでは、PHPのドキュメントを1として<html>

+0

http://php.net/manual/en/function.mail.php – vietnguyen09

+0

良いものを読むためにメッセージ領域を取得する方法についてconfussed ...ありがとう – NewCodeMan

答えて

1

<?php 
// Multiple recipients 
$to = '[email protected], [email protected]'; // note the comma 

// Subject 
$subject = 'Birthday Reminders for August'; 

// Message 
$message = ' 
<html> 
<head> 
    <title>Birthday Reminders for August</title> 
</head> 
<body> 
    <p>Here are the birthdays upcoming in August!</p> 
    <table> 
    <tr> 
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th> 
    </tr> 
    <tr> 
     <td>Johny</td><td>10th</td><td>August</td><td>1970</td> 
    </tr> 
    <tr> 
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td> 
    </tr> 
    </table> 
</body> 
</html> 
'; 

// To send HTML mail, the Content-type header must be set 
$headers[] = 'MIME-Version: 1.0'; 
$headers[] = 'Content-type: text/html; charset=iso-8859-1'; 

// Additional headers 
$headers[] = 'To: Mary <[email protected]>, Kelly <[email protected]>'; 
$headers[] = 'From: Birthday Reminder <[email protected]>'; 
$headers[] = 'Cc: [email protected]'; 
$headers[] = 'Bcc: [email protected]'; 

// Mail it 
mail($to, $subject, $message, implode("\r\n", $headers)); 
?> 
+0

ええ、そこにそれを見た。私は2つのヘッダー "MIME"& "コンテンツタイプ"が欠けていた - ありがとう – NewCodeMan

関連する問題