Heim >Backend-Entwicklung >PHP-Tutorial >为什么我运行后,总提示SMTP:Could not authenticate,我不知道该修改哪里?
1、liuyan.php如下:
include("class.phpmailer.php");
include("class.smtp.php");
//你只需填写一下信息即可****************************
$smtp = "smtp.163.com";//必填,设置SMTP服务器 QQ邮箱是smtp.qq.com ,QQ邮箱默认未开启,请在邮箱里设置开通。网易的是 smtp.163.com 或 smtp.126.com
$youremail = '123@163.com'; // 必填,开通SMTP服务的邮箱;也就是发件人Email。
$password = "123456"; //必填, 以上邮箱对应的密码
$ymail = "su.li1001@163.com"; //收信人的邮箱地址,也就是你自己收邮件的邮箱
$yname = "捷豹科技"; //收件人称呼
//填写信息结束 ****************************
function get_ip(){
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip = "unknown";
return($ip);
}
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $smtp;
$mail->Username = $youremail;
$mail->Password = $password; //必填, 以上邮箱对应的密码
$mail->From = $youremail;
$mail->FromName = "反馈系统";
$mail->AddAddress($ymail,$yname);
if($_POST['yourname']){
$yourname = $_POST['yourname'];
$tel = $_POST['tel'];
$qq = $_POST['qq'];
$email = $_POST['email'];
$message = $_POST['message'];
$ip = get_ip();
$mail->Subject = $yourname."-【留言反馈】";
$html = '姓名:'.$yourname.'
电话:'.$tel.'
QQ:'.$qq.'
邮箱:'.$email.'
IP:'.$ip.'
内容:'.$sm;
$mail->MsgHTML($html);
$mail->IsHTML(true);
if(!$mail->Send()) {
echo '<script>alert("提交失败了!");history.go(-1);</script>';
} else {
echo '<script>alert("提交成功!感谢你的反馈。");history.go(-1);</script>';
}
}
?>
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
你未通过认证:
1:确认你的$youremail / $password 是正确的
2:确认你的邮箱开通了POP3/SMTP服务功能,看你邮箱里是否收到一封设置向导邮件
化繁从简,将里面所有功能和样式都注释掉
先发一个abc到另一个邮箱再说