【发布时间】:2016-10-28 08:34:17
【问题描述】:
我在尝试通过 PHPMailer 发送电子邮件时遇到此错误:
已弃用: preg_replace():/e 修饰符已弃用,请在 /home/u722941258/public_html/old/account/access/mailer/class.phpmailer.php 中改用 preg_replace_callback 1727 行
SMTP -> 错误:连接服务器失败:连接超时 (110)
SMTP 错误:无法连接到 SMTP 主机。
PHP 代码:
function send_mail($email,$message,$subject)
{
require_once('mailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.sparkpostmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'USER';
$mail->Password = 'SECRET';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->AddAddress($email);
$mail->SetFrom('admin@email.sosgram.ga','Verificación de Cuentas');
$mail->AddReplyTo("soporte@email.sosgram.ga","Soporte SOSgram");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
}
有什么办法吗?
SMTP:http://sparkpost.com
【问题讨论】:
-
您可以尝试另一个端口号以及另一个 SMTPSecure 如 456 , ssl。
-
@Soni Vimal 我已经尝试过了,但不起作用。 SparkPost 只使用 TLS 端口 587 和 2525