I'm getting this errors while trying to send an email via PHPMailer:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/u722941258/public_html/old/account/access/mailer/class.phpmailer.php on line 1727
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.
The PHP Code:
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('[email protected]','Verificación de Cuentas');
$mail->AddReplyTo("[email protected]","Soporte SOSgram");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
}
Any solution?
Hosting: http://hostinger.es
SMTP: http://sparkpost.com
Looks like outgoing port is blocked in your server. You can try using port 2525
.
If that's also blocked, you can either open one of those two or use php client library which uses port 80/443 and it's very unlikely for those ports to be blocked;