SMTP Error cocould not connect to SMTP host. send fail

Source: Internet
Author: User

(1) The server cannot send emails using smtp.

Solution: the solution listed by many websites is due to the smtp case sensitivity problem. Although the problem is not here in essence, it must be changed. For the reason, refer to the following operations.

In class. phpmailer. php, set:

function IsSMTP(){$this->Mailer='smtp';}

Changed:

function IsSMTP(){$this->Mailer = 'SMTP';}

The modification in this place does not use smtp to send emails, but uses another method to send emails. Check that the class. phpmailer. php file contains the following section:

Switch ($ this-> Mailer) {case 'sendmail': return $ this-> SendmailSend ($ header, $ body); case 'smtp ': // because SMTP and smtp are not equal, the following MailSend mail is selected instead of sending the MAIL return $ this-> SmtpSend ($ header, $ body) using smtp; default: return $ this-> MailSend ($ header, $ body );}

(2) The fsockopen () function is disabled on the Linux host.

Many domestic space service providers disable the fsockopen function of the server for security reasons.

Solution:

Replace fsockopen () with the pfsockopen () function. If the pfsockopen function is disabled, you can replace it with other Socket functions, such as stream_socket_client ()

Change @ fsockopen to @ pfsockopen in class. smtp. php.

Set

$this->smtp_conn = @fsockopen($host,    // the host of the server                                 $port,    // the port to use                                 $errno,   // error number if any                                 $errstr,  // error message if any                                 $tval);   // give up after ? secs

Changed:

$this->smtp_conn = @pfsockopen($host,    // the host of the server                                 $port,    // the port to use                                 $errno,   // error number if any                                 $errstr,  // error message if any                                 $tval);   // give up after ? secs

(3) firewall security setting rules. If neither of the above solutions works properly, it is estimated that the firewall rules are faulty. You can ask the server administrator to remove all firewall rules and test them, check whether this is the reason.

Articles you may be interested in
  • Fatal error Call to undefined function date_default_timezone_set ()
  • Fatal error Class 'soapclient' not found in... troubleshooting method
  • Fatal error Class 'ziparchive 'not found...
  • Php prompts PHP Warning: date (): It is not safe to rely on the... solution to the error
  • Php prompts Maximum execution time of 30 seconds exceeded... solution to the error
  • Common Values of Cache-control include private, no-cache, max-age, and must-revalidate.
  • How to solve the Call to undefined function curl_init error in php running?
  • Php Output Control: understanding the differences between ob_flush and flush

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.