Pukhraj Suthar
Pukhraj Suthar

Reputation: 198

PHP SMTP issue - unable to connect to ssl

I am using smtp mail setting and send mail successfully, but some time get below error, please help me what is error in code.

----ERROR---

283 and in the file:home/xxx/public_html/xxx/class.smtp.php

stream_socket_client(): unable to connect to ssl://smtp-relay.gmail.com:465 (Network is unreachable)

Array
(
    [host] => ssl://smtp-relay.gmail.com
    [port] => 465
    [timeout] => 300
    [options] => Array (  )
    [streamok] => 1
    [errno] => 0
    [errstr] =>
    [socket_context] => Resource id #66
)

# SMTP Settings
$mail->Host = 'smtp-relay.gmail.com';
$mail->Port = '465';
$mail->Username = '[email protected]';
$mail->Password = '$$xxxxxxxx$$';
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true; 
$mail->IsSMTP(); 
$mail->IsHTML(true);
$mail->SetFrom($GLOBALS["smtp_from_email"], $GLOBALS["smtp_from_name"]);
$mail->CharSet = 'UTF-8';
# SMTP Settings

Upvotes: 0

Views: 1595

Answers (1)

Evinn
Evinn

Reputation: 153

did you use phpmailer ?

if you do

$mail->SMTPSecure ='tls'

and make sure that you telnet first to the smtp port that you use, to make sure that your network connection or the port that you going to use can be use

Upvotes: 1

Related Questions