public function actionDelete($id) { $pk = SubscribeEmail::primaryKey(); $pk = $pk[0]; $condition = [$pk => $id]; $model = SubscribeEmail::findOne($condition); if (null !== $model) { SubscribeEmail::deleteAll($condition); } return Yii::$app->response->redirect('email-list', 301); }
public function sendEmail($id) { if (null === $id) { return; } $subscribeEmail = new SubscribeEmail(); $pk = $subscribeEmail->primaryKey(); $pk = $pk[0]; if (null === $pk) { return; } $sEmail = $subscribeEmail->findOne([$pk => $id]); Yii::$app->mail->compose('@app/views/notifications/newsletter/notify.php', ['name' => $sEmail->name])->setTo($sEmail->email)->setFrom(Yii::$app->mail->transport->getUsername())->setSubject(Yii::t('app', 'New info'))->send(); }