本文介绍了尝试让SMTP与PHP联系表单一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试让SMTP以联系方式工作,我用来将信息发送到电子邮件。这是它的HTML。当我点击提交按钮时,它只是转到newsendform.php页面,该页面只是空白。有什么想法吗?
I am trying to get SMTP to work in a contact form i am using to send info to an email. Here is the HTML for it. When i hit the submit button it just goes to the newsendform.php page which is just blank. Anyone have any ideas?
<form action="newsendform.php" method="POST"> <legend>Request a FREE Quote Now!</legend> <div class="inputs"> <input type="text" id="inp_name" name="name" required placeholder="Name *" style=" width: 90%;"> <input type="text" id="inp_phone" name="number" required placeholder="Phone*" style=" width: 90%;"> <input type="text" id="inp_cmail" name="email" required placeholder="Email*" style=" width: 90%;"> <textarea name="comments" id="input_1_5" class="textareasmall" tabindex="6" rows="10" cols="50" placeholder="Message" style=" width: 90%; padding-left: 5px; border-radius: 4px; height: 105px; margin: 2px 25px 2px 0; border: none; font-size: 16px; line-height: 1.3; "></textarea> </div> <div class="submit_button"><input type="submit" name="btnSubmit" value="Request My Quote"></div> </form>PHP如下:
The PHP is as follows:
<? ob_start(); if(isset($_POST['btnSubmit'])) { require("class.phpmailer.php"); $mail = new PHPMailer(); //Your SMTP servers details $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "example.secureserver"; // specify main and backup server or localhost $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "example@example.ca"; // SMTP username $mail->Password = "11111"; // SMTP password $mail->Port = 80; $redirect_url = "thankyou.php"; //Redirect URL after submit the form $mail->From = $mail->Username; //Default From email same as smtp user $mail->FromName = "Drywall Pros"; $mail->AddAddress("myname@gmail", "Myname"); //Email address where you wish to receive/collect those emails. $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $_POST['email']; $message = "Name :".$_POST['name']." \r\n <br>Email Adrress :".$_POST['email']." \r\n <br> Phone number :".$_POST['number']."\r\n <br> Message: ".$_POST['comments']."\r\n <br> ; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; header("Location: $redirect_url"); } ?>推荐答案
_POST [' btnSubmit'])) { require( class.phpmailer.php); _POST['btnSubmit'])) { require("class.phpmailer.php");
mail = new PHPMailer(); // 您的SMTP服务器详细信息 mail = new PHPMailer(); //Your SMTP servers details
mail-> IsSMTP(); // 设置邮件程序使用SMTP mail->IsSMTP(); // set mailer to use SMTP
更多推荐
尝试让SMTP与PHP联系表单一起使用
发布评论