I have this function that whenever an admin posts a new announcement, it sends an email to all the users of the forum:
$currentid = Yii::app()->db->createCommand("select id from content where id = (select max(id) from content)")->queryRow();
Yii::app()->session['announcement_message'] = 'You have successfully created an announcement.';
$url = Yii::app()->createAbsoluteUrl('announcement/view/id/'. $currentid["id"]);
if(Yii::app()->partyroles->isAdmin())
{
$this->emailAll($url);
}
$this->redirect(array('view','id'=>$model->id));
the emailAll() is another function that I made to do the actual mail sending but since there could be 100's to 1000's of emails in the future, the sending would be slow! Whenever I click the "create" button, it usually takes around 30 seconds before it redirects back to the view page since it takes a while to send all of those emails.
My question is if there's any way to speed this up? Or is there any clever way to perhaps show the user that "Email's are being sent, please wait?"