SMTP connect()失败的PHPmailer 7.3

时间:2019-05-08 06:55:41

标签: phpmailer

我正在使用以下代码通过php mailer发送邮件,但我不断收到

  

SMTP connect()失败错误。

当我从PHP5.7转换到7.3时开始

<?php require_once('../includes/PHPMailer.php')?>
<?php require_once('../includes/Exception.php')?>
<?php require_once('../includes/SMTP.php')?>
<?php
use PHPMailer\PHPMailer\PHPMailer;
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'mail.fosg.in';
$mail->SMTPAuth = true;
$mail->Username = 'mailnotification@fosg.in';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->SMTPAutoTLS = false;
$mail->Port = 587;
$mail->setFrom('mailnotification@fosg.in', 'FOSG NOTIFICATION');
$mail->AddAddress($email, $name);
$mail->AddReplyTo('info@fosg.in', 'Information');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $template;
$to = $name." <".$email.">";
if($mail->send()) {  // some code  } 
else { //some other code }
?>

0 个答案:

没有答案