Send mail SMTP Error Could not connect to SMTP host. Solution to send fail _php tutorial

Source: Internet
Author: User
(1) The server cannot send mail using SMTP

Workaround: Many sites listed the solution is because of the SMTP case, although the nature of the problem is not here, but do need to change this place, as for why, look at the following operation.

In class.phpmailer.php, you will:

function Issmtp () {$this->mailer= ' SMTP ';}

Change to:

function Issmtp () {$this->mailer = ' SMTP ';}

Instead of using SMTP to send mail, this place uses a different way to send mail, checking the class.phpmailer.php file for the following paragraph:

Switch ($this->mailer) {case ' SendMail ': Return $this->sendmailsend ($header, $body); case ' SMTP ':// Because SMTP and SMTP are not equal, the following mailsend is selected to send mail instead of sending mail using SMTP return $this->smtpsend ($header, $body);d Efault:return $this- >mailsend ($header, $body);}

(2) the Fsockopen () function is disabled for Linux hosts

There are many space service providers in China to disable the server's Fsockopen function for security reasons.

Workaround:

Use the Pfsockopen () function instead of fsockopen (), and if the Pfsockopen function is also disabled, you can replace the socket function with other operations, such as Stream_socket_client ().

Change @fsockopen into a @pfsockopen in class.smtp.php

Put

$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

Change to:

$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 settings rules, if the above two scenarios are not effective, it is estimated that the firewall rules, you can let the server administrator remove all firewall rules, and then test to see if 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 ... Error handling methods
    • Fatal error Class ' ziparchive ' not found ... The solution
    • PHP tip php warning:date (): It is not safe to rely on the ... The wrong solution
    • PHP Tip maximum execution time of seconds exceeded ... The wrong solution
    • Web cache control Cache-control common values are private, No-cache, Max-age, Must-revalidate Introduction
    • How to troubleshoot PHP run with a call to undefined function Curl_init error
    • PHP Output Control In-depth understanding of the difference between Ob_flush and flush

http://www.bkjia.com/PHPjc/764172.html www.bkjia.com true http://www.bkjia.com/PHPjc/764172.html techarticle (1) The server cannot send mail in the form of SMTP solution: Many websites list the solution is because of the SMTP case, although the nature of the problem is not here, but really ...

  • 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.