1

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

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

当我尝试发送邮件时,它给了我错误 as-SMTP 错误:无法连接到 SMTP 主机。那么我需要做哪些额外的设置

4

1 回答 1

0

我有一个类似的错误。原来服务器重新启动后,DNS设置在centos中变为空白。设置它们后,一切都开始工作了。希望能帮助到你。

于 2013-08-02T11:14:11.667 回答