我无法突然发送google smtp服务

时间:2018-11-03 12:14:29

标签: php smtp gmail

对不起,我的英语不好。

我在Mac上的php中使用Google SMTP服务。

我的代码使用得很好。但是突然间它不起作用了。而且我试图更改我的SMTP电子邮件密码,但是它仍然无法正常工作。

我该怎么办

我的代码在这里

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require '/Applications/mampstack-7.1.20-1/apache2/htdocs/mailer/vendor/autoload.php';

$mail = new PHPMailer(true);                              // Passing `true` enables exceptions
try {
//Server settings
$mail->isSMTP(true);                                      // Set mailer to use SMTP
$mail->SMTPDebug = 1;                                 // Enable verbose debug output
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '-----@gmail.com';                 // SMTP username
$mail->Password = '---------';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to
$get_mail = $_GET["email"];

//Recipients
$mail->setFrom('CarEventManager@gmail.com', 'CarManager');


// $mail->addAddress($get_mail, 'Police');     // Add a recipient
$mail->addAddress($get_mail, 'Police');     // Add a recipient


// $body = '<p><strong>Hello<br>This is event video that you want</strong></p>';
$body = 'HI';

//Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

//Content
$aaaaa = glob("/Users/mac_pc/Downloads/*.mp4");

$file = implode($aaaaa);
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = 'Video File From BlockBox';
$mail->AddAttachment( $file, 'EventVideo.mp4' );

$mail->Body    = $body;

$mail->AltBody = strip_tags($body);

$mail->send();    // <<-- i think ERROR ON HERE 

echo 'Send Message.';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>

调试源在这里

2018-11-03 12:05:09 CLIENT -> SERVER: EHLO localhost
2018-11-03 12:05:09 CLIENT -> SERVER: AUTH LOGIN
2018-11-03 12:05:09 CLIENT -> SERVER: <credentials hidden>
2018-11-03 12:05:09 CLIENT -> SERVER: <credentials hidden>
2018-11-03 12:05:10 CLIENT -> SERVER: MAIL FROM:<CarEventManager@gmail.com>
2018-11-03 12:05:10 CLIENT -> SERVER: RCPT TO:<ysc1230@naver.com>
2018-11-03 12:05:10 CLIENT -> SERVER: DATA

0 个答案:

没有答案