私のサイトでは、PHPメールフォームを使用しています。私はメールをうまく受信しますが、私が得ているヘッダは[email protected]
という形であり、返信アドレスも同じです。ヘッダーに人の名前を取得するためにコードを変更するにはどうすればよいですか?私は次のコードを使用しています:PHPメールフォーム - メールヘッダー
<?php
if(isset($_POST['submit'])) {
$to = '[email protected]' ; //put your email address on which you want to receive the information
$subject = 'Message - Contact Form Coast Med Spa'; //set the subject of email.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mailheader = "From: ".$_POST["FirstName"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$message = "<table>
<tr><td>Title</td><td>".$_POST['Title']."</td></tr>
<tr><td>First Name</td><td>".$_POST['FirstName']."</td></tr>
<tr><td>Last Name</td><td>".$_POST['LastName']."</td></tr>
<tr><td>E-Mail</td><td>".$_POST['Email']."</td></tr>
<tr><td>Phone Number</td><td>".$_POST['HomePhone']."</td></tr>
<tr><td>Comments</td><td>".$_POST['CAT_Custom_869']."</td></tr>
<tr><td>Contact Method</td><td>".$_POST['CAT_Custom_868']."</td></tr>
<tr><td>Subscribe to: eNewsletter</td> <td>".$_POST['CampaignList_41798']."</td></tr>
</table>" ;
mail($to, $subject, $message, $headers, $mailheader);
header('Location: http://coastlasercenter.com/html/message-contact.html');
echo "Your message has been received";
}
?>
'PHPmailer'のようなメーラークラスを使うのがよいでしょう。ビルドインの 'mail()'関数は、今日の電子メールの標準には合致せず、そのようなものを変更するのは難しいです。 – Corubba