我在 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 主机。那么我需要做哪些额外的设置