Search code examples
phpemailyiiphpmailermailer

How to send mail to multiple recipients in Yii2 mailer


This code is working for a single recipient but not for multiple recipients.How should I add multiple recipient into send() function in here.

//find price
$price = MDealPrice::model()->find("id=:id", array(':id' => $id));

// find deal
$deal = MDeal::model()->find("id=:id", array(':id' => $price->dealId));

//send email
app()->mailer->send($sendEmailAdd, 'orderAuthorizeEmail', array('deal' => $deal));

I tried like this also, But not worked.

//send email
app()->mailer->send(array('[email protected]','[email protected]'), 'orderAuthorizeEmail', array('deal' => $deal));

Thanks in advance!


Solution

  • Please try with below solution it will work

     app()->mailer->send('[email protected],[email protected]', 'orderAuthorizeEmail', array('deal' => $deal));
    

    just add your email ids comma separated string in send function instead to pass array of email ids.