首页 > 解决方案 > 如何在 Magento 2 中结束邮件时附加 PDF?

问题描述

在单击发送电子邮件时的销售 > 发票中,我需要将 PDF 附加到电子邮件中。我正在使用 Magento 2.3.3。

$pdf = 'path to pdf';
$this->configureEmailTemplate();

$this->transportBuilder->addTo(
 $this->identityContainer->getCustomerEmail(),
 $this->identityContainer->getCustomerName()
);

$copyTo = $this->identityContainer->getEmailCopyTo();

if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') {
   foreach ($copyTo as $email) {
       $this->transportBuilder->addBcc($email);
   }
}

//$transport = $this->addAttachment($pdf, $pdfFileName);
$transport = $this->transportBuilder->addAttachment($pdf, 'test');
$transport = $this->transportBuilder->getTransport();
$transport->sendMessage();`


   

我尝试将 addAttachemtment 函数写入自定义的 transportBuilder 页面。但它没有用。

有谁知道如何做到这一点?

标签: phpmagentomagento2

解决方案


推荐阅读