1

I just modified a time before my IndexController.php just to be able to send emails to multiple recipients and it was working fine. I took it from magento.stackexchange. This is what I have now:

$recipients = array(
    'web@domain.com' => 'Web · Domain',
    'extra@domain.com' => 'Extra · Domain'
);

$mailTemplate->setDesignConfig(array('area' => 'frontend'))
    ->setReplyTo($post['email'])
    ->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
        array_keys($recipients),
        array_values($recipients),
        array('data' => $postObject)
    );

And now I would like to do a modification. Set the extra@domain.com email as Bcc instead of Cc because we don't want to remove extra@domain.com the whole time from recipients when we want to answer the contact form. We see the user email and the extra email when trying to answer from web@domain.com which is an email used by different people on our company. So we want extra@domain.com just as an information email which will never be used to answer emails. Is this possible at all?

SOLUTION:

$recipients = array(
    'web@domain.com' => 'Web · Domain'
);


$mailTemplate->setDesignConfig(array('area' => 'frontend'))
    ->setReplyTo($post['email'])
    ->addBcc("extra@domain.com")
    ->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
        array_keys($recipients),
        array_values($recipients),
        array('data' => $postObject)
    );
2

You can do something like this

$bccRecipients = array(
    'extra@domain.com' => 'Extra · Domain'
);

$mailTemplate->addRecipients($bccRecipients, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);

Or just try

$mailTemplate->addBcc("some@email.com");
  • As simple as adding addBcc("extra@domain.com"). Thank you! – danibg Dec 9 '15 at 9:26
1

Try this:

$recipients = array(
    'web@domain.com',
    'extra@domain.com'
);

$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
if ($recipients) {
// Add bcc to email
    foreach ($recipients as $email) {
        $emailInfo->addBcc($email);
    }
}
0

Add BCC to Magento Contact Us.

Go to Admin Panel->System->Configuration->Contacts. You are able to see Send Email To in Email Options section. Now, if you want to add Send Email BCC to this section.

  1. copy contacts extension folder from app/code/core/Mage/Contacts to paste app/code/local/Mage/Contacts.

  2. Open app/etc/modules/Mage_All.xml (Go to line No: 360) change the code pool core to local.

<Mage_Contacts> <active>true</active> <codePool>local</codePool> <depends> <Mage_Core/> </depends> </Mage_Contacts>

  1. Open app/code/local/Mage/Contacts/etc/system.xml, and find below code(Line 67)

    <recipient_email translate="label"> <label>Send Emails To</label> <frontend_type>text</frontend_type> <validate>validate-email required-entry</validate> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </recipient_email>

Add below code after above code in system.xml

<recipient_email2 translate="label"> <label>Send Emails BCC</label> <frontend_type>text</frontend_type> <sort_order>11</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </recipient_email2>

  1. Open app/code/local/Mage/Contacts/controllers/IndexController.php (Go to line: 37) add below code.

    const XML_PATH_EMAIL_RECIPIENT2 = 'contacts/email/recipient_email2';

Then Go to line number: 94 and find below code.

 $mailTemplate = Mage::getModel('core/email_template');
            /* @var $mailTemplate Mage_Core_Model_Email_Template */
            $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                ->setReplyTo($post['email'])
                ->sendTransactional(
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                    null,
                    array('data' => $postObject)
                );

Then replace with below code:

$bcc_str = Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT2);
                $bcc_email = explode(",", $bcc_str);

                $mailTemplate = Mage::getModel('core/email_template');
                /* @var $mailTemplate Mage_Core_Model_Email_Template */
                $mailTemplate->addBcc($bcc_email)
                        ->setDesignConfig(array('area' => 'frontend'))
                        ->setReplyTo($post['email'])
                        ->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), 
null, 
array('data' => $postObject));
  1. Flush magento cache and check Admin Panel->System->Configuration->Contacts. Now you are able to see Send Emails BCC in Email Options section.

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.