Add BCC in Magento Transactional Email

泄露秘密 提交于 2020-01-13 09:44:50

问题


I created a new email template, and that works fine in Magento, but I don't know how to add BCC addresses to the email.


回答1:


You can add a bcc in the code where you send the email:

Mage::getModel('core/email_template')
     ->addBcc('em@ail.com')
     ->sendTransactional(...



回答2:


This is the answer I've found:

 $mailTemplate->setTemplateSubject($mailSubject)->addBcc('youremail@mail.com')
->s‌​endTransactional($templateId, $sender, $email, $cus_name, $data, $storeId);



回答3:


You can do it in the config. Go to Sales > Sales E-Mails. Foreach transactional E-Mail you can enter Send Order Email Copy To and set the Method to BCC via Send Order Email Copy Method.




回答4:


single email or array email is acceptable, check this :

app\code\core\Mage\Core\Model\Email\Template.php

Mage_Core_Model_Email_Template

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



回答5:


Create di.xml: app/code/Py/Custom/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="\Magento\Framework\Mail\Template\TransportBuilder">
        <plugin name="TransportBuilderPlugin" type="Py\Custom\Plugin\Mail\Template\TransportBuilder" sortOrder="1" />
    </type>
</config>

Create Plugin: app/code/Py/Custom/Plugin/Mail/Template/TransportBuilder.php

<?php

namespace Py\Custom\Plugin\Mail\Template;

class TransportBuilder
{
    public function afterGetTransport(\Magento\Framework\Mail\Template\TransportBuilder $subject, $result)
    {
        $result->getMessage()->addCc('test@gmail.com');     
        return $result;
    }
}



来源:https://stackoverflow.com/questions/14641673/add-bcc-in-magento-transactional-email

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!