问题描述
将错误视为SMTP错误:无法进行身份验证。
发送邮件时出现问题。
它在localhost中工作,但是上传到服务器后显示
getting the error as SMTP Error: Could not authenticate.
Problem in Sending Mail.
It is working in localhost, but after uploading to server it is showing
SMTP错误:无法进行身份验证。
发送邮件时遇到问题。
SMTP Error: Could not authenticate.
Problem in Sending Mail.
我尝试过:
What I have tried:
require('phpmailer / class.phpmailer.php');
$ mail = new PHPMailer();
$ mail-> IsSMTP();
$ mail-> SMTPDebug = 0;
$ mail-> SMTPAuth = TRUE;
$ mail-> SMTPSecure =tls;
$ mail-> Port = 587 ;
$ mail-> Username =******@gmail.com;
$ mail->密码=****** ***;
$ mail-> Host =smtp.gmail.com;
$ mail-> Mailer =smtp;
$ mail-> SetFrom($ _ POST [userEmail],$ _ POST [userName]);
$ mail-> AddReplyTo($ _ POST [userEmail ],$ _POST [userName]);
$ mail-> AddAddress([email protected]);
$ mail-> Subject = $ _POST [subject];
$ mail-> WordWrap = 80;
$ mail - > MsgHTML($ _ POST [content]);
if(is_array($ _ FILES)){
$ mail- > AddAttachment($ _ FILES [ 'attachmentFile'] [ 'tmp_name的值'],$ _ FILES [ 'attachmentFile'] [ '名称']);
}
$ mail-> IsHTML(true);
if(!$ mail-> Send()){
echo
发送邮件时出现问题。
require('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Username = "******@gmail.com";
$mail->Password = "*********";
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->SetFrom($_POST["userEmail"], $_POST["userName"]);
$mail->AddReplyTo($_POST["userEmail"], $_POST["userName"]);
$mail->AddAddress("[email protected]");
$mail->Subject = $_POST["subject"];
$mail->WordWrap = 80;
$mail->MsgHTML($_POST["content"]);
if(is_array($_FILES)) {
$mail->AddAttachment($_FILES['attachmentFile']['tmp_name'],$_FILES['attachmentFile']['name']);
}
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "
Problem in Sending Mail.
联系邮件发送。
推荐答案
这篇关于Smtp错误:无法进行身份验证。发送邮件时出现问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!