Link to home
Start Free TrialLog in
Avatar of FDMilwaukee
FDMilwaukeeFlag for United States of America

asked on

CC email address on php email form

I am a novice when it comes to php, and I am trying to figure out how to add an email address to a form processing script.  The script is designed ot take an email address, or multiple email addresses from an input form, and send it to the aforementioned address.  I want to send a CC to a constant email address.  

This script is a "send listing to a friend" script function of an ecommerce platform, and I want to always send a copy to myself.  

See the attached file below.  This is a file from the Magento ecommerce platform

Thanks in advance for your help

FDM
Sendfriend.php
Avatar of HyperBPP
HyperBPP

I am not familiar with MAGE, however, have you tried setting the email to a semi-colon delimited list of email address.  It isn't the CC field, but it should be a work-around.

laddy@addy.com;cool@guy.com
According to http://docs.magentocommerce.com/Mage_Core/Mage_Core_Model_Email_Template.html there is a addBCC($bcc) method that would at least allow you to add a blind carbon copy.
Avatar of FDMilwaukee

ASKER

Hyper.

I did try adding semi-colon to the email section, however I never got it to work.  I have very little knowledge of PHP, I would be fine with using the semi colon method.

I had not looked at the template file before.  Using that info how would I make it work as shown with the code from their example?

Thanks a lot for your help.  Any suggestion on where a novice such as myself could bone up on some basic PHP?

Thanks again

FDM
public function addBcc($bcc)
    {
        if (is_array($bcc)) {
            foreach ($bcc as $email) {
                $this->getMail()->addBcc($email);
            }
        }
        elseif ($bcc) {
            $this->getMail()->addBcc($bcc);
        }
        return $this;
    }

Open in new window

Google is your friend  :)

Insert this on line 76 of your code, it should work.
$this->_emailModel->addBcc($email);
.
.
        $this->_emailModel = Mage::getModel('core/email_template');
        $message = nl2br(htmlspecialchars($this->_sender['message']));
        $sender  = array(
            'name' => strip_tags($this->_sender['name']),
            'email' => strip_tags($this->_sender['email'])
            );
		$this->_emailModel->addBcc($email);
        foreach($this->_emails as $key => $email) {
            $this->_emailModel->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId()))
            ->sendTransactional(
                Mage::getStoreConfig(self::XML_PATH_SENDFRIEND_EMAIL_TEMPLATE),
                $sender,
                $email,
                $this->_names[$key],
                array(
                    'name'          => $this->_names[$key],
                    'email'         => $email, 
                    'product_name'  => $this->_product->getName(),
                    'product_url'   => $this->_product->getProductUrl(),
                    'message'       => $message,
                    'sender_name'   => strip_tags($this->_sender['name']),
                    'sender_email'  => strip_tags($this->_sender['email']),
                    'product_image' => Mage::helper('catalog/image')->init($this->_product, 'small_image')->resize(75),
                )
            );
        }
.
.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HyperBPP
HyperBPP

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WOOO HOOO, you're the best!!!
thanks for the help
Glad I could help,  Happy programming!