1

This is my code:

$mail = Mage::getModel('core/email');
        $mail->setToName('My Name');
        $mail->setToEmail('email1@gmail.com','email2@gmail.com');
//        $mail->setToEmail($this->getStoreSalesEmail(), $this->getCustomerEmail());
        $mail->setBody($html);
        $mail->setSubject('You have changed your subscription date');
        $mail->setFromEmail('noreply@myemail.com');
//        $mail->setFromName("Msg to Show on Subject");
        $mail->setType('html');// YOu can use Html or text as Mail format

I received the email to this address: email1@gmail.com. But for email2@gmail.com I do not receive any email. Why ?

3

You can send using below code:

$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()
);

EDIT:

$mail->setToEmail(array('email1@gmail.com','email2@gmail.com'));
  • I am not using a template. I am just sending an email with a short text to multiple addresses. Thats why i am using Mage::getModel('core/email'), not Mage::getModel('core/email_template') – Attila Naghi Jun 24 '16 at 8:39
  • updated answer check it – Prashant Valanda Jun 24 '16 at 8:43
  • Thx a lot , this works for me :) – Attila Naghi Jun 24 '16 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.