7

我创建了一个新的电子邮件模板,它在 Magento 中运行良好,但我不知道如何将密件抄送地址添加到电子邮件中。

4

5 回答 5

13

您可以在发送电子邮件的代码中添加密件抄送:

Mage::getModel('core/email_template')
     ->addBcc('em@ail.com')
     ->sendTransactional(...
于 2013-02-01T09:29:23.043 回答
6

这是我找到的答案:

 $mailTemplate->setTemplateSubject($mailSubject)->addBcc('youremail@mail.com')
->s‌​endTransactional($templateId, $sender, $email, $cus_name, $data, $storeId);
于 2014-10-30T06:09:53.413 回答
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.

于 2013-02-01T08:33:46.900 回答
1

单个电子邮件或数组电子邮件是可以接受的,请检查:

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;
}
于 2014-09-22T08:46:03.950 回答
0

创建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>

创建插件: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;
    }
}

于 2019-02-24T15:28:50.247 回答