magento2 email

magento2-mail_tracker:Magento 2的邮件跟踪器扩展 Magento 2的邮件跟踪器 跟踪从您的Magento平台发送的所有促销和交易电子邮件。 您将了解每封电子邮件的发送时间以及客户何时打开它们 立即下载

定义邮件模板 (<Module>/etc/email_templates.xml)

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="module_hello_email_template" label="Test Mail" file="hello.html" type="html" module="Infinity_Base" area="frontend"/>
</config>

创建邮件模板 (<Module>/view/frontend/email/hello.html)

<!--@subject {{trans "Welcome to %store_name" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}

<p class="greeting">Hello {{trans "%name," name=$name}}</p>

{{template config_path="design/email/footer_template"}}

发出邮件

$templateId = 'module_hello_email_template';
$templateParams = ['name' => 'william'];

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/* @var \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder */
$transportBuilder = $objectManager->get('Magento\Framework\Mail\Template\TransportBuilder');
/* @var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager = $objectManager->get( 'Magento\Store\Model\StoreManagerInterface' );
/* @var \Magento\Customer\Helper\Session\CurrentCustomer $customer */
$customer = $objectManager->get( '\Magento\Customer\Helper\Session\CurrentCustomer' );

$transportBuilder->setTemplateIdentifier($templateId)
    ->setTemplateOptions(['area' => 'frontend', 'store' => $storeManager->getStore()->getId()])
    ->setTemplateVars($templateParams)
    ->setFrom('general') // sales,support,custom1,custom2
    ->addTo($customer->getCustomer()->getEmail(), $customer->getCustomer()->getFirstname())
    ->getTransport()
    ->sendMessage();

获取邮件模板代码

// template id, 通常在email_templates.xml定义。如果是在后台加的email template,需要换成template的记录ID,例如90
$identifier = 'contact_email_email_template';
/* @var \Magento\Framework\Mail\TemplateInterface $templateFactory */
$templateFactory = $this->_objectManager->create(
    'Magento\Framework\Mail\TemplateInterface',
    ['data' => ['template_id' => $identifier]]
);
// 模板变量,取决于phtml或后台email template的内容
$dataObject = new \Magento\Framework\DataObject();
$dataObject->setData('name', 'william');
// 决定模板变量取值区域,例如像{{layout}}这样的标签,如果取不到值可以试试把area设为frontend
$templateFactory->setOptions([
    'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
    'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID
]);
$templateFactory->setVars(['data' => $dataObject]);
return $templateFactory->processTemplate();

获取所有邮件模板的位置(powershell)

ls -Recurse vendor\magento\*\ | where {$_.Name -eq "email_templates.xml"} | foreach {
    $modulePath = $_.Directory.Parent.FullName
    $emailTemplatesXml = [xml](get-content $_)
    $emailTemplatesXml.config.template | foreach {
        $file = $_.GetAttribute("file")
        $area = $_.GetAttribute("area").toString()
        write-host "(Label):"$_.GetAttribute("label").toString()    "(ID):"$_.GetAttribute("id").toString()    "(file):"$modulePath\view\$area\email\$file
    }
}

关于模板变量

虽然通过email_templates.xml找到邮件模板很容易,但模板中使用的变量是PHP端提供的,模板变量只能在发送邮件的时候定义,所以如果要调整模板变量往往不太好找。以下列出自带组件含模板变量定义部分的代码位置

vendor/magento/module-sales/Model/Order/Email/Sender/*.php
vendor/magento/module-customer/Model/EmailNotification.php
vendor/magento/module-send-friend/Model/SendFriend.php

有趣的是order相关的email有event可以追加模板变量,例如email_order_set_template_vars_before,但并不是所有官方开发的邮件变量都有event可用。

官方的邮件变量定义代码都在Model里,但第三方组件就未必。其实也并不难找,只要对组件全代码搜索 ->setTemplateVars( ,就可以很容易找到。

CreareSEO:Magento 1的免费SEO扩展 最新版本 1.5- 关于CreareSEO for Magento 这是一个免费的Magento扩展程序,具有一系列功能,可帮助Magento更加符合最新的搜索引擎标准。 最终目的是通过对商店的配置进行一些小的调整,使您的商店在Google中的排名更高。 此扩展在Magento Connect上不再可用。 兼容性 Magento Community Edition 1.4至1.9在大多数版本的Enterprise Edition中均已成功测试 安装 在您的Magento根目录中解压扩展ZIP文件 清除Magento缓存:“系统”>“缓存管理” 注销Magento管理员,然后重新登录以清除ACL列表 如果您使用的是Magento编译器,请重新编译 用法 我们的官方包含一个视频和有关如何使用扩展的版本1的进一步说明。 但是,自从录制了视频以来,我们进行了许多改进,并增加了许多新功能。 立即下载

相关推荐

clean-magento:测试技能magento 2

清洁剂 测试技能magento 2

magento 邮件原理系列教程2

这一节我们来看下如何在自己的module中配置和使用邮件模板 1、首先我们要建立自己的Module(怎么建module不在这节的讨论范围内)Giftcards 2、在module的config.xml中添加email的全局配置 giftcards_email_email_template只要保证全局唯一就可,但为了跟system.xml配合,推荐这

clh604的专栏 1479

magento-2-email-attachments:Magento 2 电子邮件附件扩展使管理员能够附加必要的文件,如 PDF 发票、发货、贷记凭证以及向销售电子邮件添加条款和条件。 通过此扩展程序,客户可以在购买过程中通过查看来自商店的电子邮件来跟踪所有信息

Magento 2 电子邮件附件扩展 使管理员能够附加必要的文件,如 PDF 发票、发货、贷记凭证以及向销售电子邮件添加条款和条件。 通过此扩展程序,客户可以通过查看来自商店的电子邮件来了解购买过程中的所有信息。 1.文件 2. 常见问题 问:我收到错误:Mageplaza_Core 已经定义 答:阅读解决方案。 问:收件人会看到收件人的电子邮件完整列表吗? 答:有 2 种电子邮件发送选项:抄送和密件抄送。 CC 向所有人显示完整列表,而 BCC 隐藏此列表。 问:条款和条件附件是否支持其他文件格式而不是 .doc? 答:绝对可以,可能的文件格式为.pdf,.doc,.docx,.txt 问:此扩展是否与其他扩展兼容? 答:是的,电子邮件附件与和正确兼容。 问:邮件会成功到达收件人吗? A:从默认的 Magento 2 服务器发送的电子邮件可能被判断为未注册的电子邮件,这意

在Magento 2中自定义电子邮件模板

详情情趣官网 电子邮件是网店营销策略和品牌推广的重要组成部分,这使得电子邮件模板的创建和定制成为电子商务中一个相当热门的话题。在本文中,我将分析如何自定义Magento 2.3.0字母模板的各种选项。 如果浏览不顺畅请到原文章出处:https://www.sky8g.com/technology/1025/ 请注意可能会提示风险,这是优快云网站设置的问题,如果文章内的链接不是他们的网址,都...

jimbooks的博客 2014

KiCad自动布线实战:FreeRouting插件安装与使用指南

在PCB设计流程中,布线环节往往占据大量重复性工作,尤其对于中小型双面板,成百上千条飞线的手动连接既繁琐又易出错。自动布线技术通过算法在给定设计规则和元件布局的基础上自动规划走线路径,能显著提升布线效率。FreeRouting作为一款开源自动布线器,与KiCad通过DSN/SES标准中间格式无缝配合,让工程师将精力集中于关键信号和布局优化,而将常规网络交给工具处理。本文从自动布线的原理与边界出发,讲解了FreeRouting的安装、DSN导出、参数设置、自动布线及结果回传的完整流程,并结合实际案例展示了在S

weixin_32025789的博客 283

Halcon实战:5分钟搞定工业零件中的圆孔检测(附完整代码)

本文详细解析了如何利用Halcon的hough_circle算法在5分钟内高效完成工业零件中的圆孔检测。通过优化图像采集、智能预处理和参数化边缘检测,解决了金属反光、油污干扰等工业场景常见问题,并提供了完整的代码示例和实战案例,显著提升检测精度和效率。

weixin_29061997的博客 244

magento2 邮件模板中直接调用 block文件

magento2 邮件模板中直接调用 block文件 有些邮件模板我们想直接写在phtml里面 好想法 示例 {{block class="Magento\Framework\View\Element\Template" order=$order name="order_sms" template="[vendor]_[module]::[filename].phtml" area="frontend"}} 介绍 class 必写 固定 Magento\Framework\View\Element\T

huangkang1995的博客 537

个人整理的数据集(手写中文数据、发票数据、快递单数据、车牌数据)

本人在工作生活中收集了各个方面比较多的真实的数据集如下: 一、手写中文数据集 1、档案类数据: 此数据集为手写档案数据,数量较大,大约128G,图像均未标注。 ex: 2、手写作文数据: 此数据集为手写作文数据,是大约800M左右,图像按行提供位置和内容标注,十分珍贵。 ex: 二、发票数据集: 1、增值税发票 此数据集包含了大量真实的增值税发票数据,大约9G,标注了发票位置数据,未提供详细标注。 ex: 2、购车发票 此数据集未提供标注。

weixin_43143224的博客 5885

magento email:快速实现发送自定义邮件

当我们对magento email机制有一定的了解之后,便可以在模块中使用自定义邮件模板快速实现发送邮件功能!登入后台system->Transactional Emails,单击右上角Add New Template,选择一个已存在的template,单击Load Template 修改Template Information的内容,包括Template Name ,Template Su

xmlife的专栏 2016

Computers & Security 投稿实战:从零到一详解避坑指南

本文详细解析了向《Computers & Security》投稿的全流程避坑指南,包括ORCID账号注册、文件格式统一、Editorial Manager®系统操作技巧等关键步骤。特别强调了cover letter撰写、Declaration of Interest Statement准备以及PDF生成后的检查要点,帮助研究者高效完成投稿流程。

weixin_29228203的博客 677

dify1.3.1应用服务与数据服务分离,附件及插件包迁移至minio,实现离线部署,保证插件正常运行

dify1.3.1应用服务与数据服务分离,附件及插件包迁移至minio,实现离线部署,保证插件正常运行

Time_1023的博客 1875

修改MAGENTO2.1默认邮件模板

Customize email templatesEmail templates are stored in the &lt;module_dir&gt;/view/&lt;area&gt;/email directory of their respective modules. For example, the template for the new order transactional e...

qq_32150361的博客 1588

大众点评爬虫实战:如何用Python绕过反爬机制获取评论数据(附完整代码)

本文深入探讨了2024年使用Python进行大众点评数据采集的实战策略。文章详细解析了现代反爬机制的核心逻辑,并提供了从构建拟人化请求会话、应对动态内容与接口加密,到工程化实践(代理调度、状态持久化)的完整解决方案与代码示例,旨在帮助数据分析师稳健获取评论数据,用于后续的文本挖掘与商业洞察。

weixin_29084111的博客 1922

magento2:前端调试email方式

tip: 1.email写less在media断点里面写不能用&符号,不生效 2.手机端在media断点里面不生效 (手机端样式不在断点里写,pc端样式写断点里) step1: 找到vendor/magento/framework/Mail/Template/TransportBuilder.php 文件第 410行添加: echo $content;exit; step2: 在pup文件夹下找health_check.php文件,把文件里面改写为 下面的内容 <?php require

Sol的博客 359

【笔记篇】Davinci Configurator OS模块(上)

主要讲解了AUTOSAR OS配置项和Vector MICROSAR OS的特性

weixin_47571898的博客 2274

【地图模块算法】二维全局地图的开源方案及对比--gmapping、hector、karto、cartographer

系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 TODO:写完再整理 文章目录系列文章目录前言一、gmapping算法建图【基于Raoo-Blackwellized粒子滤波(RBPF)算法】1.gmapping理论(1)gmapping的工作原理(2)gmapping的算法流程(3)gmapping论文理论2.gmappingROS工程框架解析(1)gmapping的功能包架构(2)gmapping订阅和发布的话题(3)gmapping算法建图参数(4)gmapping源码

qq_35635374的博客 3438

magento2 email order totals顺序调整

totals是指购买订单信息下面的一个汇总价格信息,一般有小计、扣折、运费、税率等价格信息。通常情况下按系统的就可以,但无奈magento2这个顺序不合理,这个问题在magento2.1仍然存在,所以只能自己手动改。 app/design/frontend/Forever/theme/Magento_Sales/templates/ema...

weixin_34366546的博客 180

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

magento2 创建订单发货信息,包含Tracking Number和History Comment和Email

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34419321的博客 1029

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Magento email模版修改

<br />Magento has a great set of options to manage the Email Templates. Here we are going to see how to create our own Email templates for forgot password and how to change the magento default Email Templates and change the Email Sender options etc.

似水年华 1866

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

magento发送email

magento的发送邮件有两种形式,直接发送邮件和邮件队列。 邮件发送的相关方法在 ..\app\code\core\Mage\Core\Model\Email 直接发送邮件: $mailTemplate = Mage::getModel('core/email_template'); $currentStoreId = Mage::app()->getStore()-&...

qq_36619427的博客 538

Magento 发送邮件 How to send Email in magento

1.Use following code &lt;?php $mail = Mage::getModel('core/email'); $mail-&gt;setToName('Your Name'); $mail-&gt;setToEmail('Youe Email'); $mail-&gt;setBody('Mail Text / Mail Content'); $mail-&gt...

Just Code 431

Magento2 设置邮件模板

打开菜单,(注意:本例子只是对下单邮件模板的使用示例,其他模板调整步骤类似,按需设置;3.选择需要修改的原始模板进行调整,本例子选择的是下单成功返回的邮件模版。选择模版后点击Load Template会出现默认的模版内容。点击Preview Template可对邮件模版进行预览。调整完成后点击保存,保存的新模板会储存在邮件模版列表。找到下单邮件模板设置区域。取消锁定,选择所需模版。设置成功后点击保存即可。

qq_44889261的博客 281

magento2邮件调试方法

order mail 直接打印到页面上 位置 vendor\magento\module-sales\Model\Order\Email\Sender.php Magento\Sales\Model\Order\Email\Sender::prepareTemplate() 添加代码 $objectManager = \Magento\F...

weixin_33842304的博客 407

如何修改Magento邮件模板

 如何修改Magento邮件模板 邮件在电子商务中扮演着重要的绝色,Magento 默认邮件模板都是带着官方的标志和一些官方的基本信息。为什么建立品牌形象我们当然要把邮件模板中的所有官方信息换成自己的信息。修改步骤如下: 1、找到邮件模板(这里以en_US为例),找到如下文件: magento\app\locale\en_US\template\email\accoun

iiiiiiiiiiii9的专栏 1925
上一篇: magento2 数据库查询
下一篇: magento2 前端表单验证
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值