-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()'。这里有两种不同的动物 –