Home  >  Article  >  Backend Development  >  求教,在本地用QQ邮箱的SMTP为什么发送不了邮件,SMTP服务我开启了啊。

求教,在本地用QQ邮箱的SMTP为什么发送不了邮件,SMTP服务我开启了啊。

WBOY
WBOYOriginal
2016-06-20 12:37:161829browse

require_once "email.class.php";	//******************** 配置信息 ********************************	$smtpserver = "smtp.qq.com";//SMTP服务器	$smtpserverport =25;//SMTP服务器端口	$smtpusermail = "1322175332@qq.com";//SMTP服务器的用户邮箱	$smtpemailto = $_POST['toemail'];//发送给谁	$smtpuser = "1322175332@qq.com";//SMTP服务器的用户帐号	$smtppass = "";//SMTP服务器的用户密码	$mailtitle = $_POST['title'];//邮件主题	$mailcontent = "<h1>".$_POST['content']."</h1>";//邮件内容	$mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件	//************************ 配置信息 ****************************	$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.	$smtp->debug = false;//是否显示发送的调试信息	$state = $smtp->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype);	echo "<div style='width:300px; margin:36px auto;'>";	if($state==""){		echo "对不起,邮件发送失败!请检查邮箱填写是否有误。";		echo "<a href='index.html'>点此返回</a>";		exit();	}	echo "恭喜!邮件发送成功!!";	echo "<a href='index.html'>点此返回</a>";	echo "</div>";


回复讨论(解决方案)

邮箱密码 $smtppass是空的

邮箱密码 $smtppass是空的

在这里没写上去,测试的时候我加了的。

现在用的是授权码

现在用的是授权码

密码换成授权码?为什么还是不行。

需要用Base64编码

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn