$emails = Email::find()
->joinWith(['emailRecipients' => static function (ActiveQuery $query) {
$query->andWhere(['email_recipient.status' => EmailRecipient::EMAIL_RECIPIENT_STATUS_NEW]);
}])
->where(['email.status' => Email::EMAIL_STATUS_NEW])
->asArray()
->all();