在警予添加其余电子邮件的建议我创建了一个文件MessengerCommand.php protected/commands
下为要使用crontab的
class MessengerCommand extends CConsoleCommand
{
public function run($args)
{
/* if(ERunActions::runBackground())
{ */
$mail=Yii::app()->Smtpmail;
$mail->SetFrom("[email protected]", 'From NAme');
$mail->Subject ="hello";
$mail->MsgHTML("haiii workd");
$mail->AddAddress("[email protected]", "");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}else {
echo "Message sent!";
}
}
}
,并添加yiic
命令
$path = dirname(__FILE__);
//echo $path;
shell_exec($path . "/protected/yiic messenger");
,它会触发电子邮件当我加载该网站....
但我不想刷新该网站..我需要使这个在后台运行..请帮助我。
你解决了你的问题吗? –
还没有,仍然试图 – rch
请看我的答案,希望它可以帮助你 –