PHP Mail导致错误:& quot;标题丢失& quot; [英] PHP Mail results in error: "header missing"
问题描述
我已经使用php邮件表单已有一段时间了,现在它不能在新网站上使用了.
I've been using a php mail form for some time now and now it's not working on a new website.
以下错误结果:
PHP警告:mail()[function.mail]:"sendmail_from"未在php.ini或自定义发件人:"中设置第16行的E:\ home \ -mypagefoldername- \ Web \ form.php中缺少标头
PHP Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in E:\home\ -mypagefoldername- \Web\form.php on line 16
这是form.php文件中的php代码:
This is the php code in the form.php file:
<?
$mensagem = "Nome: ".$_POST['nome']." \n";
//email que o usuário preencheu
$mensagem .= "Email: ".$_POST['email']." \n";
$mensagem .= "Assunto: ".$_POST['assunto']." \n";
$mensagem .= "Telefone: ".$_POST['fone']." \n";
$mensagem .= "Endereço: ". $_POST['mensagem'];
$headers = "";
//email do seu domínio hospedado
$emailsender = "email@mydomain.com";
//email de quem vai receber
$emaildestinatario = "email@mydomain.com";
$assunto = "Mensagem do Parceiro Pipa";
// Envio dos dados do Formulário para seu e-mail:
if(!mail($emaildestinatario, $assunto, $mensagem, $headers ,"-r".$emailsender))
{
// Se for Postfix - hospedagem linux
$headers .= "Return-Path: " . $emailsender . $quebra_linha;
}
echo '
<script type="text/JavaScript">
alert("Email sent! Thank you!");
location.href="index.html"
</script>
';
?>
对不起葡萄牙语.
表单页面是具有以下表单代码的简单html页面:
The form page is a simple html page with the following form code:
<form method="post" action="form.php">
<label>Nome</label>
<input name="nome" placeholder="Nome completo.">
<label>Telefone</label>
<input name="fone" placeholder="Número de telefone com DDD.">
<label>Assunto</label>
<input name="assunto" placeholder="Qual o motivo do seu contato?">
<label>Mensagem</label>
<textarea name="mensagem" placeholder="Escreva aqui sua mensagem."></textarea>
<label>Email</label>
<input name="email" type="email" placeholder="Email para contato.">
<input id="submit" name="submit" type="submit" value="Enviar">
</form>
有人可以帮我吗?=/
感谢您的耐心!
推荐答案
请在php.ini文件中更改以下设置
Please change the following settings in php.ini file
要启用电子邮件,您应该取消注释以下行或在行首删除分号
to enable email you should uncomment the following line or remove the semicolon at the begining of the line
;sendmail_from =
,然后将此设置更改为此(例如,如果是localhost)
and change this setting to this for example (if localhost)
sendmail_from = localhost@localhost
如果您在生产服务器上,则必须根据您的域来更改默认地址,因此,administrator @ domain.com
if you are on a production server you have to change the default address according to your domain, so administrator@domain.com
这篇关于PHP Mail导致错误:& quot;标题丢失& quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!