【发布时间】:2015-08-12 10:09:29
【问题描述】:
我有一个名为 formulario.html 的 html 表单,当他提交并成功时,它会重定向到名为 agradecimentos.html 的第二个页面。 一切进展顺利,但我没有收到他发送到的 2 封电子邮件中表格中的信息。 提前感谢您的帮助。
这是 formulario.html 代码的一部分:
<form action="suporte_email.php" method="post" name="formulario" id="formulario" >
<!-- THAT'S TOO MUCH CODE BUT I CHECKED THAT AND IT SEEMS NOT TO BE WRONG -->
<input type="submit" name="submit" class="button" value="Enviar" />
</form>
agradecimentos.html 是一个简单的 html 代码,我在其中将客户端重定向到该站点的页面。
我的 .php 代码被命名为 suporte_email.php,就像您可以看到操作在哪里一样。我的问题是我没有收到表单中的信息,我仍然不知道我的错误在哪里。
suporte_email.php
<?php
$crlf = "\r\n";
//Get Data
$nome = $_POST['nome'];
$empresa = $_POST['empresa'];
$contacto = $_POST['contacto'];
$email = $_POST['email'];
$marca = $_POST['marca'];
$other = $_POST['other'];
$serial_number = $_POST['serial_number'];
$garantia = $_POST['garantia'];
$contrato = $_POST['contrato'];
$permissoes = $_POST['permissoes'];
$descricao_avaria = $_POST['descricao_avaria'];
$checkbox = $_POST["checkbox"];
$radio = $_POST["radio"];
// Parse/Format/Verify Data
$to = "teste@teste.pt, $email";
$from = "Suporte";
$subject = "Formulário de Suporte";
$email_body = "$crlf De: $nome$crlf Email: $email$crlf Assunto: $subject$crlf$crlf Empresa: $empresa$crlf Contacto: $contacto$crlf Marca: $marca$crlf Outra: $other$crlf Número de Série: $serial_number$crlf Garantia: $radio$crlf Contrato: $checkbox$crlf Tipo de Suporte: $permissoes$crlf$crlf Descrição da Avaria: $descricao_avaria";
// Setup EMAIL headers, particularly to support UTF-8
// We set the EMAIL headers here, these will be sent out with your message
// for the receiving email client to use.
$headers ='From: '.$to . $crlf .
'Reply-To: ' .$to . $crlf .
'Content-Type: text/plain; charset=UTF-8' . $crlf .
'X-Mailer: PHP/' . phpversion();
// Then we pass the headers into our mail function
mail($to, $from, $subject, $email_body, $headers);
header('Location: agradecimentos.html');
?>
//Garantia 是一个单选按钮,Contrato 是一个复选框。
【问题讨论】:
-
您的系统上有邮件服务器吗?
mail()返回一个状态,老实说它没有多大用处,但看看它是个好主意,如果它返回 false 可能会输出错误 -
另外,您正在对您的邮件发送进行零错误检查。
-
是的,我有一个邮件服务器@RiggsFolly 好的.. 但它仍然会发生相同的情况,信息不会被发送
-
哼.. 你有什么建议让它工作@Epodax? :)
-
和一个简单的邮件呼叫工作?即:
mail('teste@teste.pt', 'My Subject', 'testing 1-2-3');