我這個指南: http://www.w3schools.com/php/php_mail.asp是否可以編寫整個電子郵件並使用PHP命令發送?
所以按照本指南操作可我真的打開此頁面我在Chrome或其他互聯網稱爲「email.php」發送電子郵件給自己([email protected])瀏覽器嗎?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<h1> Email Application </h1>
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "Some Guy";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
</body>
</html>
我試着在本地看到上面看到的email.php,但沒有任何反應。我需要將email.php放在服務器上嗎?
我目前正在處理聯繫表單,並且希望將所有在聯繫表單字段中輸入的信息發送到指定的電子郵件地址。我正在爲一家公司的網站做這件事。
PHP;如果你只是在本地打開文件,它不會做任何事情。 – andrewsi
@andrewsi這是正確的,再加上你還需要一個與它一起運行的「郵件服務器」。 – reikyoushin
'網絡主機'是您的第一步,然後是奶油和肉汁。但是,您發佈的代碼不會執行任何操作;好吧,有點。 –