Advertisement
filebot

Use IP and 'peer_name' => 'ssl://smtp.mailgun.org' to workaround mailgun connection timeout issues

Dec 24th, 2024
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.     $remote_socket = 'ssl://34.160.13.42:465';
  3.  
  4.     // Set ssl context options, see http://php.net/manual/en/context.ssl.php
  5.     $options['ssl'] = array('peer_name' => 'ssl://smtp.mailgun.org', 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => false);
  6.     $socket_context = stream_context_create($options);
  7.  
  8.     $socket = @stream_socket_client($remote_socket, $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $socket_context);
  9.  
  10.     if (!$socket)
  11.     {
  12.         echo $errno.' '.$errstr."\n";
  13.         return;
  14.     }
  15.  
  16.     $server_response = fgets($socket, 256);
  17.     echo $server_response;
  18.  
  19.     fclose($socket);
  20. ?>
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement