<div class="contact_form clearfix" id="Contact">
<h2><a href="#header">Hello... You can send me message to my universe here.</a></h2>
<a href="#header"><img src="img/planeta1.png" alt=""> </a>
<form class="clearfix spaceForm" action="contactform.php" metod="post" >
<label for="name">Your name:</label>
<input type="text" name="name" id="name" placeholder="Jon Doe" required>
<label for="email">Your email:</label>
<input type="text" name="email" id="email" placeholder="something@mama.com" required>
<label for="subject">Subject</label>
<input type="text" name="subject" id="subject" required>
<label for="message">Your message:</label>
<textarea name="message" id="message" required></textarea>
<button type="submit" name="submit">Send mail</button>
</div>
and php code here...
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mailTo = "pisitenam@sammostalnisindikatstark.org.rs";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from " .$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.html");
}
?>
我的联系表改为发送信息下载在电脑上作为php文件。 我上传了我的网站到netfly,但仍然不工作。 谁能帮我提示一下问题出在哪里? 在XAMPP上,im得到空白页,邮件不发送。 当我上传网站在netfly网站工作良好,但联系人从点击提交开始下载php文件哪里是代码写的控制联系表。5天,我试图找到这个问题的解决方案,我感到很累:D所以如果有人可以帮助。。。
您的表单标记中有一些拼写错误,首先更正代码中的方法拼写,因为它是不正确的,所以它不能重定向和发布您的数据到联系表单。
邮件库包含各种功能。 例如:
<?php require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'your_smtp_domain.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('john@example.net', 'John doe'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
如果您使用Library,这可以为您工作。