PHPMailer SMTP身份验证错误:无法进行身份验证
这是我的代码为我的电子邮件系统在我的网站上基于PHPMailer。 我有一个SMTP认证错误,尝试了stackoverflow的许多解决方案,检查并重新检查了每个细节、密码和电子邮件。 但这可能是我犯的一个简单错误 PHPMailer 5.2.13 PHP版本5.3.10-1ubuntu3.20 以及使用我的网络托管SMTP服务PHPMailer SMTP身份验证错误:无法进行身份验证,php,email,phpmailer,smtp-auth,Php,Email,Phpmailer,Smtp Auth,这是我的代码为我的电子邮件系统在我的网站上基于PHPMailer。 我有一个SMTP认证错误,尝试了stackoverflow的许多解决方案,检查并重新检查了每个细节、密码和电子邮件。 但这可能是我犯的一个简单错误 PHPMailer 5.2.13 PHP版本5.3.10-1ubuntu3.20 以及使用我的网络托管SMTP服务 include_once("PHPMailerAutoload.php"); $para = "testTarget@domain"; $nome
include_once("PHPMailerAutoload.php");
$para = "testTarget@domain";
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$assunto = $_POST['assunto'];
$msg = $_POST['msg'];
$mail = new PHPMailer(true);
$pop = new POP3();
$msg_final = "";
//MSG Build
$msg_final .= "Telefone: ".$telefone."\n\n<br />";
$msg_final .= "Assunto: ".$assunto."\n\n<br />";
$msg_final .= "Email: ".$email."\n\n<br /><br />";
$msg_final .= $msg;
try{
$mail->SetFrom($email, $nome);
$mail->AddReplyTo($email, $nome);
$mail->Subject = $assunto;
$mail->MsgHTML($msg_final);
$mail->AddAddress($para, "Central Pires");
$mail->CharSet = 'UTF-8';
//Doesnt work anyway
$pop->Authorise('imap.server', 143, 30, 'no-reply=server', 'pass', 0);
$mail->IsSMTP();
$mail->Host = "smtp.hostserver.domain";
$mail->SMTPSecure = "tls"; //ssl
$mail->SMTPDebug = 0;
$mail->SMTPKeepAlive = true;
$mail->SMTPAuth = true;
$mail->Port = 587; //or 465
$mail->Username = "no-reply@hostserver.domain";
$mail->Password = "password";
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
include_once(“phpmailerautoad.php”);
$para=”testTarget@domain";
$nome=$_POST['nome'];
$email=$_POST['email'];
$telefone=$_POST['telefone'];
$assunto=$_POST['assunto'];
$msg=$_POST['msg'];
$mail=新的PHPMailer(true);
$pop=新POP3();
$msg_final=“”;
//味精构建
$msg_final.=“Telefone:”.$Telefone.\n\n
;
$msg_final.=“Assunto:$Assunto.\n\n
”;
$msg_final.=“电子邮件:”.$Email.\n\n
”;
$msg_final.=$msg;
试一试{
$mail->SetFrom($email,$nome);
$mail->AddReplyTo($email,$nome);
$mail->Subject=$assunto;
$mail->MsgHTML($msg_final);
$mail->AddAddress($para,“中央Pires”);
$mail->CharSet='UTF-8';
//反正也不行
$pop->authorize('imap.server',143,30,'no reply=server','pass',0);
$mail->IsSMTP();
$mail->Host=“smtp.hostserver.domain”;
$mail->SMTPSecure=“tls”//ssl
$mail->SMTPDebug=0;
$mail->SMTPKeepAlive=true;
$mail->SMTPAuth=true;
$mail->Port=587;//或465
$mail->Username=“否-reply@hostserver.domain";
$mail->Password=“Password”;
$mail->Send();
}捕获(phpmailerException$e){
echo$e->errorMessage();
}捕获(例外$e){
echo$e->getMessage();
}
我尝试更新我的PHPMailer,检查是否启用了OpenSSL
检查了服务器端口和地址,我尝试在服务器上无回复电子邮件的情况下登录,工作正常以下是我的工作示例,可能对您有所帮助:
$strTo = array("test@test.com");
require 'PHPMailer/PHPMailerAutoload.php';
$email = new PHPMailer();
$email->From = $email_from;
$email->FromName = $name;
$email->Subject = $subject;
$email->Body = $body;
$email->AddReplyTo($email_from, $name);
foreach($strTo as $receiver){
$email->AddAddress( $receiver );
}
if(isset($_FILES['fileAttach'])){
$name_file = $_FILES['fileAttach']['name'];
$path_file = $_FILES['fileAttach']['tmp_name'];
$email->AddAttachment( $path_file ,$name_file );
}
$flgSend = $email->Send();
if($flgSend)
{
//success
}else{
//error
}
将
$mail->SMTPDebug
设置为2
,然后检查正在发生的信息<代码>$mail->SMTPDebug=2代码>密码命令失败。现在改为gmail并正常工作,但我正在尝试用我的smtp服务器解决此问题。按照@MubinKhalid所说的启用调试,并告诉我们此处显示的确切错误。为什么在IMAP端口上尝试在smtp之前执行POP?既然您也在通过SSL进行常规身份验证,为什么还要尝试这样做呢?