1
我試圖讓PHP電子郵件以HTML格式發送,但當前電子郵件只是以代碼發送。我不確定我做錯了什麼。PHP電子郵件不能以html格式發送
有沒有人看到任何東西?
ini_set('display_errors', 1);
error_reporting(E_ALL);
$project_name = $_POST['project_name'];
$title_roll = $_POST['title_roll'];
$project_email = $_POST['project_email'];
$project_number = $_POST['project_number'];
$project_description = $_POST['project_description'];
$project_source = $_POST['project_source'];
$project_socialMedia = $_POST['project_socialMedia'];
$project_humanTest = $_POST['project_humanTest'];
$to = 'email';
$subject = 'Project Inquiry Form Sent';
//$message = 'FROM: '.$project_name. "<br>" . ' Email: '.$project_email. "<br>" . 'Message: '.$project_description;
//$msgcontents = "Name: $project_name<br>Email: $project_email<br>Message: $project_description";
$message = '
<html>
<head>
<title>Project Inquiry Form Sent</title>
</head>
<body>
<p>Hi Optimum Designs Team,</p><br>
<p>There has been a Project submitted. Here are the details:</p><br>
<p>Name: '. $project_name .'</p>
<p>Name: '. $title_roll .'</p>
<p>Name: '. $project_email .'</p>
<p>Name: '. $project_number .'</p>
<p>Name: '. $project_description .'</p>
<p>Name: '. $project_source .'</p>
<p>Name: '. $project_socialMedia .'</p><br>
<p>Good Luck,</p>
<p>Administration</p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From:' .$project_email . "\r\n";
if (!empty($project_email)) {
if (filter_var($project_email, FILTER_VALIDATE_EMAIL)) {
//Should also do a check on the mail function
if (mail($to, $subject, $message, $headers)) {
echo "Your email was sent!"; // success message
} else {
echo "Mail could not be sent!"; // failed message
}
} else {
//Invalid email
echo "Invalid Email, please provide a valid email address.";
}
} else {
echo "Email Address was not filled out.";
}
完美。非常感謝你。 – Paul
@Paul你很受歡迎Paul,*歡呼聲* –