php - 如何在 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 页面。但它没有用。
有谁知道如何做到这一点?
解决方案
推荐阅读
- python - 如何实现 Q 学习来逼近最优控制?
- matplotlib - Matplotlib:在图表上每个点旁边显示值
- c++ - 二进制数和位标志“x”
- javascript - htmlunit 无法处理 javascript 模块
- python - 如何初始化需要 __new__ 和 __init__ 的对象
- c# - 为什么 x = x + 100 的处理方式与编译为相同 IL 的 x += 100 不同?
- matrix - Pyspark:按列加权平均
- python - tkinter:能够在脚本运行时单击其他按钮
- postgresql - PostgreSQL - 使用 CURSORS 将 2 个 TABLES 的数量“分配”/“隔离”到第三个 TABLE
- bash - 是否可以通过命令(如 env)“转储”所有 bash 特殊变量?