我通过表单发送简历到邮件,但是收不到邮件...请检查我的代码
这是我的表格:
<form action="Careers.php" method="post" enctype="multipart/form-data" id="uploadForm">
Name<br />
<input type="text" name="cf_name" class="input"/><br />
E-mail<br />
<input type="text" name="cf_email" class="input"/><br />
Upload your Resume<br />
<input type="file" name="attachment" size="40"/><br />
<input type="submit" value="Send" id="upload" class="color1"/>
</form>
这是我的Careers.php:
<?php
$strTo="bhargavi@genyedu.com";
$strSubject = 'Job Application from a site visitor ';
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From: ".$_POST["cf_name"]."<".$_POST["cf_email"].">\nReply-To: ".$_POST["cf_email"]."";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
//*** Attachment ***//
if($_FILES["attachment"]["name"] != "")
{
$strFilesName = $_FILES["attachment"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"] ["tmp_name"])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Mail send completed.";
}
else
{
echo "Cannot send mail.";
}
?>
我没有收到任何错误......但它说无法发送邮件......为什么我不知道......请帮助我。
如果我删除'@'符号,那么我将会出现以下错误:
Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\WebsiteTemplate3\Careers.php on line 63
嗨...我禁用了smtp服务器身份验证...现在它说成功但我没有收到任何邮件......但它说成功...请告诉我
答案 0 :(得分:0)
函数前面的@符号会抑制其错误消息(在代码中甚至会这样说)。 尝试更改此内容:
@mail($strTo,$strSubject,null,$strHeader);
到此:
mail($strTo,$strSubject,null,$strHeader);
这将为您提供错误消息,说明出现了什么问题,以便您可以修复它。