Magento邮件模板
1、Magento邮件模板语法与html语言一致;
2、邮件模板一般把css写在标签内部;
3、由于邮件阅读终端不同,多使用table标签布局;
4、邮件模板中的变量获取语法和cms静态块中的一致;
做好邮件模板需要两件事:1.div+css;2。熟悉相关变量
所有的模板可在system->TransactionalEmails中loaddefaulttemplate进行加载之后进行修改,或者直接在\app\locale\en_US\template\email下修改对应文件模板。Newsletter自动发送邮件需要服务器cron服务支持!
常见重要邮件模板配置:
1、新建帐户确认邮件-对应模板:Newaccount
System->Configuration->CustomerConfiguration->CreateNewAccountOptions->DefaultWelcomeEmail(GLOBAL)
2、订单生成邮件-对应模板:NewOrder和NewOrderforGuest
System->Configuration->SalesEmails->Order->NewOrderConfirmationTemplate(GLOBAL)
3、发货通知邮件-对应模板:NewShipment和NewShipmentforGuest
System->Configuration->SalesEmails->Shipment->ShipmentEmailTemplate(GLOBAL)
4、EmailtoFriend-对应模板:SendProducttofriend
System->Configuration->EmailtoaFriend->EmailTemplates->SelectEmailTemplate(GLOBAL)
5、Newsletter邮件订阅-对应模板:Newslettersubscriptionconfirmation/Success
System->Configuration->Newsletter->SubscriptionOptions->ConfirmationEmailTemplate(GLOBAL)
常见变量:(多部分常量在默认模板中有提示)
基础篇:
{{storeurl=""}}==>网址(相对路径)
<imgsrc="{{varlogo_url}}"alt="{{varlogo_alt}}"_area='frontend'/>==》网站LOGO
{{storeurl="customer/account/"}}==》链接到控制器
{{configpath='trans_email/ident_support/email'}}=》站点配置文件邮箱读取
{{configpath='general/store_information/phone'}}=》站点电话读取
{{varstore.getFrontendName()}}==>网店名称
客户篇
{{htmlescapevar=$customer.name}}==>客户姓名
{{varcustomer.email}}==>客户Email
{{htmlescapevar=$customer.password}}==>客户密码
{{configpath='trans_email/ident_support/email'}}==>客服邮箱
重设密码:
<ahref="{{storeurl="customer/account/resetpassword/"
_query_id=$customer.id
_query_token=$customer.rp_token}}"style="color:#1E7EC8;">
{{storeurl="customer/account/resetpassword/"
_query_id=$customer.id_query_token=$customer.rp_token}}</a>
邮件确认:
<ahref="{{storeurl="customer/account/confirm/"
_query_id=$customer.id
_query_key=$customer.confirmation
_query_back_url=$back_url}}"style="color:#1E7EC8;">
thisconfirmationlink</a>
新密码:{{htmlescapevar=$customer.password}}
产品分享篇
其它常量:
-nameRecipientname
-emailRecipientEmailaddress
-product_nameProductname
-product_urlUrlforproduct
-product_imageUrlforproductsmallimage(75px)
-messageSendercustommessage
-sender_nameSendername
-sender_emailSenderemail
订单篇
"varlogo_url":"EmailLogoImageUrl",
"varlogo_alt":"EmailLogoImageAlt",
"htmlescapevar=$order.getCustomerName()":"CustomerName",
"varstore.getFrontendName()":"StoreName",
"storeurl=\"customer/account/\"":"CustomerAccountUrl",
"varorder.increment_id":"OrderId",
"varorder.getCreatedAtFormated('long')":"OrderCreatedAt(datetime)",
"varorder.getBillingAddress().format('html')":"BillingAddress",
"varpayment_html":"PaymentDetails",
"varorder.getShippingAddress().format('html')":"ShippingAddress",
"varorder.getShippingDescription()":"ShippingDescription",
"layouthandle=\"sales_email_order_items\"order=$order":"OrderItemsGrid",
"varorder.getEmailCustomerNote()":"EmailOrderNote"}
支付失败篇:
取值:如:{{varreason}}
"varreason":"TransactionFailedReason",
"varcheckoutType":"CheckoutType",
"varcustomerEmail":"CustomerEmail",
"varcustomer":"CustomerName",
"varitems":"ShoppingCartItems",
"vartotal":"Total",
"varbillingAddress.format('html')":"BillingAddress",
"varshippingAddress.format('html')":"ShippingAddress",
"varshippingMethod":"ShippingMethod",
"varpaymentMethod":"PaymentMethod",
"vardateAndTime":"DateandTimeofTransaction"
电子订阅篇
订阅确认:{{varsubscriber.getConfirmationLink()}}
取消订阅:{{varsubscriber.getUnsubscriptionLink()}}
Contacts篇
Name: {{vardata.name}}
E-mail: {{vardata.email}}
Telephone: {{vardata.telephone}}
Comment: {{vardata.comment}}
管理密码重置篇
管理员密码:htmlescapevar=$user.name
重设密码链接:
<ahref="{{storeurl="adminhtml/index/resetpassword/"
_query_id=$user.id_query_token=$user.rp_token}}"style="color:#1E7EC8;">
{{storeurl="adminhtml/index/resetpassword/"
_query_id=$user.id_query_token=$user.rp_token}}</a>
新密码:{{htmlescapevar=$password}}
登陆:{{storeurl="adminhtml/system_account/"}}
新人欢迎邮件示例:
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;"> <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;"> <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%"> <tr> <td align="center" valign="top" style="padding:20px 0 20px 0; text-align:left;"> <!-- [ header starts here] --> <table align="center" bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;"> <tr> <td valign="top"> <a href="{{store url=""}}"><img src="{{media url="wysiwyg/header.jpg"}}" width="650" alt="{{var store.getFrontendName()}}" style="margin-bottom:10px;" border="0"/></a></td> </tr> <!-- [ middle starts here] --> <tr> <td valign="top"> <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1> <p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">Welcome to {{var store.getFrontendName()}}. To log in when visiting our site just click <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">Login</a> or <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">My Account</a> at the top of every page, and then enter your e-mail address and password.</p> <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;"> Use the following values when prompted to log in:<br/> <strong>E-mail</strong>: {{var customer.email}}<br/> <strong>Password</strong>: {{htmlescape var=$customer.password}}<p> <img src="{{media url="wysiwyg/shendanxg.jpg"}}" width="650" align="center" alt="" /> <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">When you log in to your account, you will be able to do the following:</p> <ul style="font-size:12px; line-height:16px; margin:0 0 16px 0; padding:0;"> <li style="list-style:none inside; padding:0 0 0 10px;">– Proceed through checkout faster when making a purchase</li> <li style="list-style:none inside; padding:0 0 0 10px;">– Check the status of orders</li> <li style="list-style:none inside; padding:0 0 0 10px;">– View past orders</li> <li style="list-style:none inside; padding:0 0 0 10px;">– Make changes to your account information</li> <li style="list-style:none inside; padding:0 0 0 10px;">– Change your password</li> <li style="list-style:none inside; padding:0 0 0 10px;">– Store alternative addresses (for shipping to multiple family members and friends!)</li> </ul> <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p> <img src="{{media url="wysiwyg/banner_b.gif"}}" width="650" align="center" alt="" /> </td> </tr> <tr> <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td> </tr> </table> </td> </tr> </table> </div> </body>
Magento邮件模板修改与设置
Magento中的邮件和其模版,一直是客户需求比较多的一块,但是由于测试不太方便所以一般改动的都相当不方便,也比较小。
前段时间刚好一个客户对这方面的要求比较多,于是只能硬着头皮修改测试了。这边就简单记录一下处理过程。
先从后台看起,基本的邮件设置位于System——>Configuration——>General--Store Email Addresses 中,这边就不多赘述了。
邮件模板管理位于System——>Transactional Emails ,在这边我们可以添加自定义的邮件模板。这边就以基础模板的自定义修改为例来介绍下过程。首先选择一个基础邮件模板并点击加载,
接下来就是编辑我们的自定义模板了
名称尽量以一目了然的规则来命名,如果你希望在模板中插入一些可用的变量,可以点击“插入变量(insert variable)”,然后就是编辑模板内容了,我们可以将 Template Content中的内容复制到 我们习惯的代码编辑器中进行编辑,完成后拷贝回去即可,完成模板编辑后保存即可。
然后到System——>Configuration——>Sales--Sales Emails中设置各个动作所调用的邮件模板。
然后保存测试。
当然这边只是一个过程介绍,实际操作中,为了更方便,一般使用注册用户进行测试。
上面是一个修改后的发货通知的邮件(移除了货单中的产品信息)。
如果需要修改模板细节的结构布局,比如产品选项,自定义设置等,需要在模板phtml文件中修改。 文件位于 模板的 template/email 目录下,有需要的可以去研究下代码,修改文件试试。