【发布时间】:2016-01-16 05:36:15
【问题描述】:
这是我基于 PHPMailer 的网站中电子邮件系统的代码。 而且我的 SMTP 出现身份验证错误,尝试了 stackoverflow 的许多解决方案,检查并重新检查了每个细节、密码、电子邮件。 但对我来说可能是一个简单的错误。
PHPMailer 5.2.13
PHP 版本 5.3.10-1ubuntu3.20
并使用我的虚拟主机 SMTP 服务
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();
}
我尝试更新我的 PHPMailer,检查 OpenSSL 是否已启用。
检查了服务器端口和地址,我尝试使用服务器上的无回复电子邮件登录并正常工作
【问题讨论】:
-
将
$mail->SMTPDebug设置为2并查看信息。$mail->SMTPDebug = 2; -
密码命令失败。现在改成 gmail 并且工作正常,但我正在尝试用我的 smtp 服务器解决这个问题。
-
启用调试,如@MubinKhalid 所说,并告诉我们那里显示的确切错误。
-
您为什么要在 IMAP 端口上执行 POP-before-SMTP?鉴于您也在通过 SSL 进行常规身份验证,为什么还要尝试这样做?
标签: php email phpmailer smtp-auth