尝试让SMTP与PHP联系表单一起使用

编程入门 行业动态 更新时间:2024-10-26 20:23:11
本文介绍了尝试让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联系表单一起使用

本文发布于:2023-10-09 18:01:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476393.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   SMTP   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!