Home  >  Article  >  Backend Development  >  When PHPMailer sends an email, the error message 'Could not connect to SMTP host' appears - PHP Tutorial

When PHPMailer sends an email, the error message 'Could not connect to SMTP host' appears - PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:21:251113browse


php PHPMailer is unable to connect to the host when sending emails. This is because the fsockopen function is disabled, and PHPmailer relies on this function to send emails.

Modify:


class.stmp.php


Solution:

1:


Line 118:


$this->smtp_conn = fsockopen($host, // the host of the server

changed to:

$this->smtp_conn = pfsockopen($host, // the host of the server


2:


File: class.phpmailer.php

Line 291:

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

changed to:


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


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477185.htmlTechArticlephp PHPMailer is unable to connect to the host when sending emails. This is because the fsockopen function is disabled. PHPmailer relies on this function to send emails. . Modification: class.stmp.php Solution: 1: Line 118: ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn