How to send email to multiple users in magento
email, magento, php
Solution
The answer is in `Mage_Core_Model_Email_Template::send()`
You can see that `$email` and `$names` arguments can be both arrays. So in your case if will be:
$recipients = [
'rec1@gmail.com' => 'Recipient1 Name',
'rec2@gmail.com' => 'Recipient2 Name'
];
Mage::getModel('core/email_template')->sendTransactional(
$templateId,
$sender,
array_keys($recipients),
array_values($recipients),
$vars,
$store->getId()
);
Problem
This is my code that is working fine when I'm sending it to one recipient, i.e if I'm using `'rec1@gmail.com'` (single email) it is working fine. However I want to include the second email id as well `rec2@gmail.com` and writing code like this: `'rec1@gmail.com,rec2@gmail.com'` but this is not working. Let me know how can I implement this functionality ? ``` $templateId = 1; $sender = array( 'name' => 'swapnesh', 'email' => 'sender@gmail.com' ); $store = Mage::app()->getStore(); $vars = array( 'my_var' => 15, 'another_var' => 12 ); $translate = Mage::getSingleton('core/translate'); // Send your email Mage::getModel('core/email_template')->sendTransactional( $templateId, $sender, 'rec1@gmail.com,rec2@gmail.com', 'Recipient Name', $vars, $store->getId() ); $translate->setTranslateInline(true); ```