php - 如何在 magento 2.x 中使用 TransportBuilder 发送 iCal 会议请求
问题描述
我想将iCal
会议请求与邮件集成(在 中magento 2.2.4 v
)。我正在尝试以下方式,但它不起作用。请帮忙。
.bin
它在带有文件的邮件中显示为附件
TransportBuilder.php
namespace Vendor\module\Magento\Mail\Template;
class TransportBuilder extends \Magento\Framework\Mail\Template\TransportBuilder
{
const TYPE_TEXTCALENDER="text/calendar";
public function addAttachment(
$body,
$filename = null,
$mimeType = self::TYPE_TEXTCALENDER,
$disposition = \Zend_Mime::DISPOSITION_ATTACHMENT,
$encoding = \Zend_Mime::ENCODING_BASE64
) {
$this->message->createAttachment($body, $mimeType, $disposition,
$encoding, $filename);
return $this;
}
}
发送邮件代码:-
.............
$transport = $this->_transportBuilder-
>setTemplateIdentifier('template_identifier')
->setTemplateOptions($templateOptions)
->setTemplateVars($templateVars)
->setFrom($from)
->addTo($to)
->addAttachment($ical)
->getTransport();
$transport->sendMessage();
请检查下面使用的示例 ical 文件的链接:- https://gist.github.com/DeMarko/6142417
解决方案
推荐阅读
- php - 在 wordpress 中,在新页面上上传图片,但这些图片显示在前端
- awk - 每条记录后的空行和换行中的列
- angular - 没有分页的角度材料数据表加载非常缓慢
- django - 如何使用 MultiEmailAlternatives 嵌入带有 html 的图像?
- c# - 仅使用 .net Regex 仅获取第 N 次出现的字符串
- c# - B2C 自定义注册 - 使用外部 API 调试声明交换
- javascript - jQuery - 在页面加载时将表单的属性设置为 true
- geoip - 如何下载GeoLite2-Country.mmdb.gz 现在需要添加访问码
- flutter - 通过传递自定义列表显示颤振图
- docker - 如何使用 WLST 创建新的 Unix 机器