首页 文章

问题在localhost中发送电子邮件但不在liveserver中发送[重复]

提问于
浏览
0

这个问题在这里已有答案:

我有PHPMailer的问题 . 首先,我已经集成了phpmailer和电子邮件,在localhost和live server中没有任何问题 . 从昨天开始,我有一个问题是在localhost中发送电子邮件但在实时服务器中没有 . 我在localhost发送电子邮件时遇到的错误是

无法将电子邮件发送给最近批准的会员 . ErrorSMTP connect()失败 . https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

这与在live server和localhost中发送电子邮件的代码相同 .

$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'someone@gmail.com';                 // SMTP username
$mail->Password = $pw;                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;                                    // TCP port to connect to
$mail->setFrom('someone@gmail.com', 'Reboot E-Magazine');
$mail->addAddress($email);     // Add a recipient
$mail->Subject = 'Article Confirmation';
$mail->Body =
'Reboot Magazine
--------------------------------------------------------------------
Your article was not been approved due to certain reasons.
Please ensure the article are well-written and relevant to the topic.
--------------------------------------------------------------------

Sincerely,
Riyaz Ahmad
Admin of Reboot E-magazine';

if(!$mail->send())
{
    $error = "Email could not be sent. Error". $mail->ErrorInfo;
}
else
{
    $msg = "Email has been sent to notify the member";
}

1 回答

相关问题