Magento邮件模板
1、Magento邮件模板语法与html语言一致;
2、邮件模板一般把css写在标签内部;
3、由于邮件阅读终端不同,多使用table标签布局;
4、邮件模板中的变量获取语法和cms静态块中的一致;
做好邮件模板需要两件事:1.div+css;2。熟悉相关变量
所有的模板可在system->Transactional Emails 中load default template进行加载之后进行修改,或者直接在\app\locale\en_US\template\email下修改对应文件模板。Newsletter自动发送邮件需要服务器cron服务支持!
常见重要邮件模板配置:
1、新建帐户确认邮件-对应模板:New account
System -> Configuration -> Customer Configuration -> Create New Account Options -> Default Welcome Email (GLOBAL)
2、订单生成邮件-对应模板:New Order和New Order for Guest
System -> Configuration -> Sales Emails -> Order -> New Order Confirmation Template (GLOBAL)
3、发货通知邮件-对应模板:New Shipment和New Shipment for Guest
System -> Configuration -> Sales Emails -> Shipment -> Shipment Email Template (GLOBAL)
4、Email to Friend-对应模板:Send Product to friend
System -> Configuration -> Email to a Friend -> Email Templates -> Select Email Template (GLOBAL)
5、Newsletter邮件订阅-对应模板:Newsletter subscription confirmation/Success
System -> Configuration -> Newsletter -> Subscription Options -> Confirmation Email Template (GLOBAL)
常见变量:(多部分常量在默认模板中有提示)
基础篇:
{{store url=""}} ==>网址(相对路径)
<img src="{{var logo_url}}" alt="{{var logo_alt}}" _area='frontend'/>==》网站LOGO
{{store url="customer/account/"}} ==》链接到控制器
{{config path='trans_email/ident_support/email'}} =》站点配置文件邮箱读取
{{config path='general/store_information/phone'}} =》站点电话读取
{{var store.getFrontendName()}}==>网店名称
客户篇
{{htmlescape var=$customer.name}}==>客户姓名
{{var customer.email}}==>客户Email
{{htmlescape var=$customer.password}} ==>客户密码
{{config path='trans_email/ident_support/email'}}==>客服邮箱
重设密码:
<a href="{{store url="customer/account/resetpassword/"
_query_id=$customer.id
_query_token=$customer.rp_token}}" style="color:#1E7EC8;">
{{store url="customer/account/resetpassword/"
_query_id=$customer.id _query_token=$customer.rp_token}}</a>
邮件确认:
<a href="{{store url="customer/account/confirm/"
_query_id=$customer.id
_query_key=$customer.confirmation
_query_back_url=$back_url}}" style="color:#1E7EC8;">
this confirmation link</a>
新密码:{{htmlescape var=$customer.password}}
产品分享篇
其它常量:
- name Recipient name
- email Recipient Email address
- product_name Product name
- product_url Url for product
- product_image Url for product small image (75 px)
- message Sender custom message
- sender_name Sender name
- sender_email Sender email
订单篇
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"htmlescape var=$order.getCustomerName()":"Customer Name",
"var store.getFrontendName()":"Store Name",
"store url=\"customer/account/\"":"Customer Account Url",
"var order.increment_id":"Order Id",
"var order.getCreatedAtFormated('long')":"Order Created At (datetime)",
"var order.getBillingAddress().format('html')":"Billing Address",
"var payment_html":"Payment Details",
"var order.getShippingAddress().format('html')":"Shipping Address",
"var order.getShippingDescription()":"Shipping Description",
"layout handle=\"sales_email_order_items\" order=$order":"Order Items Grid",
"var order.getEmailCustomerNote()":"Email Order Note"}
支付失败篇:
取值:如:{{var reason}}
"var reason":"Transaction Failed Reason",
"var checkoutType":"Checkout Type",
"var customerEmail":"Customer Email",
"var customer":"Customer Name",
"var items":"Shopping Cart Items",
"var total":"Total",
"var billingAddress.format('html')":"Billing Address",
"var shippingAddress.format('html')":"Shipping Address",
"var shippingMethod":"Shipping Method",
"var paymentMethod":"Payment Method",
"var dateAndTime":"Date and Time of Transaction"
电子订阅篇
订阅确认: {{var subscriber.getConfirmationLink()}}
取消订阅:{{var subscriber.getUnsubscriptionLink()}}
Contacts篇
Name: {{var data.name}}
E-mail: {{var data.email}}
Telephone: {{var data.telephone}}
Comment: {{var data.comment}}
管理密码重置篇
管理员密码:htmlescape var=$user.name
重设密码链接:
<a href="{{store url="adminhtml/index/resetpassword/"
_query_id=$user.id _query_token=$user.rp_token}}" style="color:#1E7EC8;">
{{store url="adminhtml/index/resetpassword/"
_query_id=$user.id _query_token=$user.rp_token}}</a>
新密码:{{htmlescape var=$password}}
登陆:{{store url="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>