PHP Error fsockopen()

PHP

We get the following Error while hitting our website to create an account or sending emails from the existing accounts in our website.

**PHP Error**

**Description**

fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known

**Source File**

/var/www/html/protected/components/Email.php(1690)

01678:      * @param    string
01679:      * @return    string
01680:      */
01681:     protected function _smtp_connect()
01682:     {
01683:         $ssl = NULL;
01684:         if ($this->smtp_crypto == 'ssl')
01685:             $ssl = 'ssl://';
01686:         $this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
01687:                                         $this->smtp_port,
01688:                                         $errno,
01689:                                         $errstr,
01690:                                         $this->smtp_timeout);
01691: 
01692:         if ( ! is_resource($this->_smtp_connect))
01693:         {
01694:             $this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr);
01695:             return FALSE;
01696:         }
01697: 
01698:         $this->_set_error_message($this->_get_smtp_data());
01699: 
01700:         if ($this->smtp_crypto == 'tls')
01701:         {
01702:             $this->_send_command('hello');

Earlier we never get any PHP errors while sending emails or creating a new account in our website.

Can any one suggest us on what should be done to avoid this?

Best Answer

This is most likely a DNS resolution error. Either your server has no nameservers, the ones it is using are too slow and time out, or they can't resolve the hostname of your SMTP server to an address. Start looking there, as this is the meaning of getaddrinfo failed: Name or service not known.