Ojibix Creatives
Ojibix Creatives

Reputation: 117

SMTP Email Failed to connect socket error

I have got business email package with bigrock and was able to work with it since last 2 months but suddenly since last two days, it is throwing the error.

"Failed to connect to smtp.indianvisaservice.org.in:587 [SMTP: Failed to connect socket: Connection timed out (code: -1, response: )]"

I am not sure what is this, here is the code

    <?php

require_once "Mail.php";

$htmlcontent = "Hi, How are you?";

$host = "smtp.indianvisaservice.org.in";
$port = "587";
$username = "[email protected]";
$password = "somepassword";
$replyto = "[email protected]";

$to = "[email protected]";
$subject = "Complete Your e-Visa Application-".$appid."";

$from = "[email protected]";
$headers = array ('From' => $from,
  'To' => $to,
  'Reply-To' => $replyto, 
  'Subject' => $subject,
  'MIME-Version' => '1.0',
  'Content-Type' => "text/html; charset=ISO-8859-1");

$smtp = Mail::factory('smtp',
    array ('host' => $host,
           'port' => $port,
           'auth' => true,
           'socket_options' => array('ssl' => array('verify_peer_name' => false)),
           'username' => $username,
           'password' => $password));

$recipients = $to;

$mail = $smtp->send($recipients, $headers, $htmlContent);    

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo "Sent Successfully.";
 }

?>

What i am doing wrong here, Any support will be thankful.

Upvotes: 0

Views: 3548

Answers (0)

Related Questions