/** * Sends an email with a link, for verifying the given email address. * @param integer $id * @return boolean whether the email was send */ public function sendActivityFollowersEmail($id) { $projectActivity = ProjectActivity::findOne($id); $project = $projectActivity->project; $userIds = explode(',', $projectActivity->followers->usersFollowing); foreach ($userIds as $userId) { $user = User::findOne($userId); if ($user) { \Yii::$app->mailer->compose('emailActivityFollower', ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name])->setTo($user->email)->setSubject('Activity update notification for ' . $project->name . ', acitivity ' . $projectActivity->name)->send(); } } $projectFollowerIDs = explode(',', $project->followers->usersFollowing); $projectFollowerIDs = array_diff($projectFollowerIDs, $userIds); foreach ($projectFollowerIDs as $userId) { $user = User::findOne($userId); if ($user) { \Yii::$app->mailer->compose('emailProjectActivityFollower', ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name])->setTo($user->email)->setSubject('Project activity update notification for ' . $project->name)->send(); } } }