SMTP错误:使用其他服务器而不是SMTP时,无法连接到SMTP主机


SMTP Error: Could not connect to SMTP host when using other server instead of SMTP

我在php中工作。我使用Yii框架的mailer扩展编写了邮件功能,代码为-

public function sendsecureEmail($FromEmail,$ToEmail,$Subject,$Message)
    {
        $settings=new Settings();
        $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
        $mailer->IsSMTP();
        $mailer->IsHTML(true);
        $mailer->SMTPAuth = true;
        $mailer->SMTPSecure = 'ssl';
        $mailer->Host =$settings->Host;
        $mailer->Port =$settings->Port;
        $mailer->CharSet = 'UTF-8';
        $mailer->Username =$FromEmail; 
        $mailer->Password =$settings->password;
        $mailer->FromName = 'balaee.com';
    //  $mailer->AddAddress($ToEmail);
        $mailer->Subject = $Subject;
        $mailer->IsHTML(true);
        $mailer->Body=$Message;
        $mailer->AddCC($ToEmail);
    //  $mailer->AddBCC=;
        if($mailer->Send())
        {
            echo "Mail send Successfully.Please you have check mail ";
        }
        else
        {
            echo "Fail to send your message!";
        }
    }

其中$setting->$Host="mail.balaee.com",$setting>$Port=25。在php.ini中,文件设置为-

SMTP = mail.balaee.com
sendmail_from = noreply@balaee.com
smtp_port = 25

当我尝试发送邮件时,它会将错误显示为SMTP错误:无法连接到SMTP主机。那么我需要什么附加设置来进行

我也有类似的错误。结果服务器重新启动后,centos中的DNS设置变为空白。设置好后,一切又开始工作了。希望能有所帮助。