<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
//$mail->SMTPDebug = 3;// Enable verbose debug output
$mail->isSMTP();// Set mailer to use SMTP
$mail->Host = '124docs.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;// Enable SMTP authentication
$mail->Username = 'infor@124docs.com';// SMTP username
$mail->Password = '#';// SMTP password
$mail->SMTPSecure = 'ssl';// Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;// TCP port to connect to
$mail->setFrom('infor@124docs.com', '124Docs');
$mail->addAddress('dulanga.weerasuriya@gmail.com', 'Dulanga');// Add a recipient
$mail->addReplyTo($_POST['email'],$_POST['name']);
//Keep it simple - don't use HTML
$mail->isHTML(false);// Set email format to HTML
$mail->Subject = 'Welcome';
//Build a simple message body
$mail->Body = <<<EOT
Email: {$_POST['email']}
Name: {$_POST['name']}
Message: {$_POST['message']}
EOT;
//Send the message, check for errors
if (!$mail->send()) {
//The reason for failing to send will be in $mail->ErrorInfo
//but you shouldn't display errors to users - process the error, log it on your server.
$msg = 'Sorry, something went wrong. Please try again later.';
} else {
$msg = 'Message sent! Thanks for contacting us.';
}
?>
This is my contact form
联系表
<?php if (!empty($msg)) {
echo "<h2>$msg</h2>"; } ?>
<form id="contact-form" method="post" enctype="multipart/form-data" action="email.php">
<fieldset>
<label for="name"><span class="text-form">Name:</span><input type="text" name="name" id="name"/></label>
<label for="email"><span class="text-form">Email:</span><input type="email" name="email" id="email"/></label>
<div class="wrapper">
<div class="text-form"><label for="message">Message:</div><textarea name="message" id="message" rows="8" cols="20"></textarea></label></div>
<div style="margin-left:75px">
<input class="form-control" id="bttn" type="reset" value="Clear">
<input class="form-control" id="bttn" type="submit" value="Send">
<div>
</fieldset>
</form>
This is my full code now email are going correctly but now my question this my contact form page not show messages. so now I need help fix this error. I use the code for show the Message but it's not work correctly. then my code this not work. some one place help me fix this error.
有两个代码,第一个是操作页面email.php和其他页面联系页面。但那时我只提到了联系页面表单代码。
联系表格显示php代码:
该图像表示它在前端页面上显示了我的php代码。实际上,我需要显示联系表单以填写所有详细信息,然后单击“发送”按钮,即成功的消息或该消息有错误。那是我需要向我显示我的联系表格。