How to send mass email based on categories of Users?

I am new for yii2, I am developing web application that sends alerts to user based on their desired categories:
i want to send list of titles with a link to users
**tender is a table with id ,title , detail.bidstatus
i am trying to send the list of tenders to a user or users
//i tried the following codes but not showing the list of tenders
public function sendEmail($email)


    return Yii::$app->mailer->compose()
        ->setFrom([$this->email => $this->name])
  1. Select all users with a certain category.
  2. foreach.
  3. Form and send email.

could please try it?, i just modified the question to get the basic knowledge

That won’t work like that.


You’re missing ->all() at the end.


$bids are not HTML, they are data. You need to form HTML from it first.