未收到Php电子邮件
我正在使用基本的php邮件功能发送电子邮件。但由于未知原因,未收到通知。我找不到代码的任何问题。有什么帮助吗?提前谢谢 PHP未收到Php电子邮件,php,html,forms,email,Php,Html,Forms,Email,我正在使用基本的php邮件功能发送电子邮件。但由于未知原因,未收到通知。我找不到代码的任何问题。有什么帮助吗?提前谢谢 PHP <?php // display form if user has not clicked submit if (!isset($_POST["submit"])) { ?> <?php } else { // the user has submitted the form // Check if the "from" in
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
<?php
} else { // the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["contact_email"])) {
$from = $_POST["contact_email"]; // sender
$subject = $_POST["contact_name"];
$message = $_POST["contact_message"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// send mail
mail("email@example.com",$subject,$message,"From: $from\n");
echo "Thank you for sending us feedback";
}
}
?>
表格
<form id="contactForm" class="cmxform" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" >
<strong>Usa il modulo sottostante per inviarci un messaggio email:</strong>
<div>
<label for="contact_name">Nome </label>
<em>(obbligatorio, almeno 2 lettere)</em><br />
<input id="contact_name" name="contact_name" size="30" class="required" minlength="2" value="" required="required" />
</div>
<div>
<label for="contact_email">E-Mail </label>
<em>(obbligatorio)</em><br />
<input id="contact_email" name="contact_email" size="30" type="email" class="required email" value="" />
</div>
<div>
<label for="contact_phone">Telefono </label>
<em>(opzionale)</em><br />
<input id="contact_phone" name="contact_phone" size="14" type="number" class="phone" value="" maxlength="14" />
<label for="contact_ext">interno </label>
<input id="contact_ext" name="contact_ext" size="5" type="tel" class="ext" value="" maxlength="5" />
</div>
<div>
<label for="contact_message">Il tuo commento </label>
<em>(obbligatorio)</em><br />
<textarea id="contact_message" name="contact_message" cols="70" rows="7" class="required"></textarea>
</div>
<div>
<input name="submit" class="submit" type="submit" value="Invia"/>
</div>
</form>
PHP邮件返回布尔值。如果邮件是由邮件发送的,则为True;如果不是,则为false。(这并不意味着消息已被接收,而只是已发送)。 尝试:
…其中一个
blah
等于“检查垃圾邮件文件夹”。旁注:您没有为>设置“类型”。注意:>发送邮件时,邮件必须包含发件人标头。这可以通过附加的_headers参数设置,也可以在php.ini中设置默认值。>否则将导致类似于警告的错误消息:mail():“sendmail_from”未在php.ini中设置或“custom”from:“header missing”。From标头还设置Windows下的返回路径。不客气。我测试了你的代码,对我来说效果很好。此外,90%的表单信息没有正确输入,但这与事实无关。(可能是因为混合了type=“text”)@Firebug,这可能是一个因素。我建议您联系您的主机提供商,询问他们您应该使用哪种邮箱(sendmail)。有些有“blat”、“Qmail”等。我自己在Linux上使用PHP的mail()
函数。您可能必须使用SMTP
,因为出于安全目的,某些主机不提供mail()
。如果为false,则表明您的php邮件程序存在一些问题。然后联系你的主人…我已经和托管提供商谈过了,没有任何关于托管问题的代码;在windows服务器上,php mailer函数不起作用。您只能发送经过身份验证的电子邮件。否则,您可以移动到基于linux的服务器,在那里您应该能够使用该功能。是的。试试这个:
var_dump(mail("email@example.com",$subject,$message,"From: $from\n"));