Home > Article > Backend Development > When PHPMailer sends an email, the error message 'Could not connect to SMTP host' appears - PHP Tutorial
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';
}