首页 > 解决方案 > PHPMailer:没有错误但不在实时服务器上发送邮件(php)

问题描述

我正在使用这段代码:

<?php
require ('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
//$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'allthingsremainhere@gmail.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = '465';
$mail->SetFrom('youcanreply@lishup.com', 'Reply It! - LishUp');
$mail->AddAddress('techgoeshere@gmail.com', 'Tech');
$mail->Subject  = 'First PHPMailer Message';
$mail->Body     = 'Hi! This is my first e-mail sent through PHPMailer.';

if(!$mail->send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
?>

我的电子邮件和密码没问题。那不是问题。stmp 连接有问题。在 Google 帐户中:2Factor 授权已关闭并且“允许安全性较低的应用”已打开

我正在使用托管在 Google Cloud 上的 Live Server。请帮我解决这个问题

标签: phpphpmailer

解决方案


推荐阅读