我正在使用phpmailer和gmail smtp,它正在为#34; tls"在我的本地xampp上,但当我在服务器邮件上移动我的项目时无法发送并给出错误:SMTP Error: Could not connect to SMTP host.
我的代码是:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Port = 587; // Or 587
$mail->Username = $admin_email;
$mail->Password = $admin_password;
$mail->SMTPSecure = 'ssl';
$mail->From = $admin_email;
// $mail->FromName= $from_name;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->addAddress($emailTo);
if (!$mail->send()){
echo "error";
}
我的代码有什么问题?