我从网上下载了一个联系脚本(带有文件附件)。我正在 wamp(pc) 中运行它,但是当我单击“提交”时,它显示此错误。您能帮我解决此错误吗
警告:mail() [function.mail]:无法连接到“localhost”端口 25 上的邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 C:\wamp 中的 ini_set()第 38 行的\www\contact.php 调用S
您能告诉我下面的脚本是否有效吗?如果不行,您能否建议一个带有文件附件的良好联系表格
<form action="" enctype="multipart/form-data" method="post">
<label for="name">Name:</label><br/>
<input type="text" id="name" name="name" /><br/>
<label for="email">Email address:</label><br/>
<input type="text" id="email" name="email" /><br/>
<label for="topic">Subject:</label><br/>
<input type="text" id="topic" name="topic" /><br/>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<label>Upload a Menu:</label>
<input type="file" name="file" size="20"><br>
<label for="comments">Your comments:</label><br/>
<textarea id="comments" name="comments" rows="5" cols="30"></textarea><br/>
<button name="submit" type="submit">Send</button>
</form>
<?php
if(isset($_POST['submit']))
{
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$topic = $_POST['topic'];
$comments = $_POST['comments'];
// Build the email (replace the address in the $to section with your own)
$to = 'my@email.com';
$subject = "Contact: $topic";
$message = "$name said: $comments";
$headers = "From: $email";
// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);
// Redirect
echo('<br> your mail has been send<br>');
}
?>
最佳答案
代码没有任何问题,切换到不同的脚本也没有帮助。
问题是您的计算机上没有运行用于发送邮件的邮件服务器。
关于php - 带有文件附件的 php 联系人脚本需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6839682/