-1
接觸形式這與以下錯誤陣列或對象:變量傳遞給每個()不是在PHPMailer的
Variable passed to each() is not an array or object
但電子郵件有白色,沒有它,沒有名字和沒有的接收者電子郵件,有什麼可能是錯的?
的index.html
<!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>Enviando email pelo PHP Através de um formulário</title>
</head>
<body>
<form action="formulario.php" method="POST">
Seu nome: <input type="text" name="nome"><br>
Seu e-mail: <input type="text" name="email"><br>
Comentários: <textarea name="comentarios"></textarea><br>
<input type="submit" value="Enviar">
</form>
</body>
</html>
formulario.php
<?PHP
// Set the message that will be sent to your e- mail below:
$mensagem = "Mensagem enviada em ".date("d/m/Y").", os dados seguem abaixo:\n";
// This loop puts all the form fields in the e- mail message to be sent
while(list($campo, $valor) = each($HTTP_POST_VARS)) {
$mensagem .= ucwords($campo).": ".$valor."\n";
}
// Now we will make PHP send the form data to your email :
mail("[email protected]", "Assunto do E-mail", $mensagem, "From: $REMOTE_ADDR");
echo "Seu e-mail foi enviado com sucesso. Obrigado";
?>
不要使用'$ HTTP_POST_VARS',請使用'$ _POST'來代替'$ HTTP_POST_VARS。 – Ikari
這不是phpmailer btw,它是php'mail()'。這裏有兩種不同的動物 –