出于某种奇怪的原因,我的 PHP 登录系统会发送一封确认电子邮件来激活您的帐户,但它不会发送任何内容。<?php$error = NULL;require "phpmailer/class.phpmailer.php";require "phpmailer/class.smtp.php";require "phpmailer/PHPMailerAutoload.php";if(isset($_POST['submit'])) { //Form Data GET $u = $_POST['u']; $p = $_POST['p']; $p2 = $_POST['p2']; $e = $_POST['e']; //Throw Username too short error if(strlen($u) < 5){ $error = "(!) Your username must be at least 5 characters."; }elseif($p2 != $p) { //Throw password pair error. $error .= "(!) Your passwords do not match :/"; }else{ //200 [OK] //Establish Connection to Database $mysqli = NEW MySQLi('localhost','root','','test'); //Convert special chars. $u = $mysqli->real_escape_string($u); $p = $mysqli->real_escape_string($p); $p2 = $mysqli->real_escape_string($p2); $e = $mysqli->real_escape_string($e); //Generate Verification Key $vkey = md5(time().$u); //Insert account into database $p = md5($p); $insert = $mysqli->query("INSERT INTO accounts(username,password,email,vkey) VALUES('$u','$p','$e','$vkey')"); if($insert){ //Start PHPMailer $mail = new PHPMailer(true); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 0; //No Debug. Set to 3 for verbose logging. $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; //Set to SSL to pass checks. $mail->Host = "smtp.mail.com"; //Set to mail.com server, it has ssl, smtp, and it's free. If you'd like to use gmail, use smtp.gmail.com $mail->Port = 465; //SSL/TLS Port for mail.com and gmail.com一开始,我需要我的 PHPMailer 文件夹中的文件,然后我启动 PHPMailer这让我很紧张。我知道问题所在。如果有人知道解决方案或知道为什么它不起作用的提示,那就太好了。谢谢。同一文件中的 HTML
1 回答
阿波罗的战车
TA贡献1862条经验 获得超6个赞
你可以试试这个我也有一个错误所以我不得不在主机之前添加这一行
$mail->SMTPOptions=array('ssl'=>array('verify_peer'=>false,'verify_peer_name'=>false,'allow_self_signed'=>false));
但如果这不起作用,您可以尝试像这样进行故障排除
if($mail->Send()){
}else{
var_dump($mail);
die();
}
所以一旦你得到你的错误日志,你可能可以做一个谷歌或粘贴你的错误日志,也许我们可以提供帮助
- 1 回答
- 0 关注
- 91 浏览
添加回答
举报
0/150
提交
取消