Pages:

How to create HTML order email?

kalanta

No avatar

2008-09-04 20:48

How to send order details as HTML email? How to create that correctly? I would like to see nicely formatted email.

» Quick.Cart v3.x

kalanta

Makaron

Avatar: Makaron

2008-09-05 09:49

Recently I done this for one of customer.. It's not so hard.. You have to add one heading to function mail() in place when You want to use html (because mails are sending in some places , and when You add this heading in global function all mails will be send in html format). This heading is: "Content-type: text/html; charset=utf-8 \r\n" and it should be added after heading which describes from who the mail it is.. After this modification You can use html tags and css styles (but only inner) in template of email..

kalanta

No avatar

2008-09-05 12:31

I need more info, 'cause I'm not a good programmer- I'm working with CSS, HTML and graphic design only. Could you explain that or paste changed code?

kalanta

Makaron

Avatar: Makaron

2008-09-05 12:56

I can't give You solution in few steps.. It's little more complicated.. and You should know html and php if You want make this modification..

aquasyl

No avatar

2008-09-06 09:50

Hey Makaron.
can you detail more this?
I have QCv2.x, is it possible to have html mail, wtih it?

Can you say where exactly you put this code ?
"Content-type: text/html; charset=utf-8 \r\n"

Do i must to put it in heading of my mail ?
In sendoredertoclient.tpl for exemple ?
<!-- BEGIN EMAIL_HEAD -->
"Content-type: text/html; charset=utf-8 \r\n"
.....here my html text .......
<!-- END EMAIL_HEAD -->

is it ok ?

Thanks

Makaron

Avatar: Makaron

2008-09-08 10:27

@aquasyl: The simpliest way to set it is to change global function which sends emails.. Edit file core/other.php You see function sendEmail? You have code like this:

@mail$sTargetEmail$sTopic$sMailContent'From: '.$sSender )


The last parameter is headings.. In this case it is only one (From: ..). You have to change it. Try in this way..

$headers .= "From: ".$sSender." \r\n";
$headers .= "Content-type: text/html; charset=utf-8 \r\n";
f( @mail$sTargetEmail$sTopic$sMailContent$headers ) ){
   
$content $tpl->tbHtml$sFile'SEND_GOOD' );
}


Should work..

aquasyl

No avatar

2008-09-08 18:40

Ok,
i found the code in the file you say, but i don't know how to do, look my code :

<?php
 $sMailContent 
changeCharset$sMailContent );
      
$sTopic       changeCharset$sTopic );

      if( !isset( 
$sTargetEmail ) )
        
$sTargetEmail $GLOBALS['config']['email'];

      if( @
mail$sTargetEmail$sTopic$sMailContent'From: '.$sSender ) ){
        
$content $tpl->tbHtml$sFile'SEND_GOOD' );
      }
      else
        
$content $tpl->tbHtml$sFile'SEND_ALERT' );
    }
    else
      
$content $tpl->tbHtml$sFile'WRONG_WORD' );
    return 
$content;
  } 
// end function sendEmail

?>



Why i must to take, and where in this code ?

Thanks

treewood (OpenSolution)

Avatar: treewood

2008-09-09 11:12

aquasyl - then change this:

if( @mail$sTargetEmail$sTopic$sMailContent'From: '.$sSender ) ){

to

if( @mail$sTargetEmail$sTopic$sMailContent'From: '.$sSender."\r\nContent-type: text/html; charset=utf-8 \r\n" ) ){

aquasyl

No avatar

2008-09-09 20:23

Ok, i do that, thanks.
But, say me ,
with this new code, can i take some html in my fr_sendOrderToClient.tpl ?

I try it, but it's no good.

I try do put :
<font color=red> Dear customer....... </font>

And my mail receive, is not in red !!

culda_a

Avatar: culda_a

2008-09-10 07:09

and how do we do send html order to client in version 3.1?

Makaron

Avatar: Makaron

2008-09-10 09:41

I see that this topic is quite popular so I try to help You.. In all versions of script (in version 3.x file core/common.php; in version 2.x file core/other.php) You have function sendEmail and code:

if( @mail$sTargetEmail$sTopic$sMailContent'From: '.$sSender ) ){


You have to change it for:

$headers .= "From: ".$sSender." \r\n";
if( @
mail$sTargetEmail$sTopic$sMailContent$headers ) ){


Now the definition of function should be changed from:

function sendEmail$aForm$sFile 'messages.tpl'$sTargetEmail null ){


for:

function sendEmail$aForm$sFile 'messages.tpl'$sTargetEmail null$headers null ){


And now in place where this function is used fe. in version 3.1 it is function which sends order to admin You can find it in file core/orders.php. This function uses function sendEmail it contains code like this:

sendEmail$aSendnull$GLOBALS['config']['orders_email'] );


When You want to use html tags in template of this mail You have to change this code for:

$headers .= "Content-type: text/html; charset=utf-8 \r\n";
sendEmail$aSendnull$GLOBALS['config']['orders_email'], $headers );

culda_a

Avatar: culda_a

2008-09-11 14:30

great , now the html content we have to put in the orders_print.tpl ?

culda_a

Avatar: culda_a

2008-09-11 21:36

I want to make a html message that is send to the client that looks like a invoice with a loge and with tables .... can you pls explain where can we put the html code?

Garry3005

No avatar

2009-07-28 01:36

I have tried for hours but cant get html mail to work. Hve added send to client and the html mail from above post it sends the html headers but can not get the sections in the correct palce on the sent email here is code not compleate but it places the user details after the items list.

<!-- BEGIN CUSTOMER_ORDER_EMAIL_TITLE -->$lang[Order_customer_info_title]$aData[iOrder]<!-- END CUSTOMER_ORDER_EMAIL_TITLE -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_HEAD -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Email Test</title>
<style type="text/css">
<!--
body {
background-color: #CCFF66;
}
-->
</style>

<div id="Layer1" style="position:absolute; width:800px; height:115px; z-index:1; left: 187px; top: 235px;">
<table cellspacing="0" border="1">
<thead>
<td colspan="4">$lang[Order_customer_products]</td><tr></tr>
<tr>
<td class="name">$lang[Name]</td>
<td class="price"><em>$lang[Price]</em><span>[$config[currency_symbol]]</span>& lt;/td>
<td class="quantity">$lang[Quantity]</td>
<td class="summary"><em>$lang[Summary]</em><span>[$config[currency_symbol]]</span& gt;</td>
</tr>
</thead>
</div>
<!-- END CUSTOMER_ORDER_EMAIL_HEAD -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_LIST -->
<td align="left">|n| $aData[sName]</td><td align="right">|n| $aData[sPrice]</td><td align="center">|n| $aData[iQuantity]</td><td align="right">|n| $aData[sSummary]</td><tr></tr>
<!-- END CUSTOMER_ORDER_EMAIL_LIST -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_BODY -->
$aData[sProducts]
<div id="Layer1" style="position:absolute; width:400px; height:115px; z-index:1; left: 318px; top: 0px;">
<table>
<td>$aData[sFirstName] $aData[sLastName]<br>$aData[sCompanyName]<br>$aData[sStreet]<br>$aData[sCity] $aData[sZipCode]<br>$aData[sPhone]<br>$aData[sEmail]</br> </td>
</table>
</div>
<!-- END CUSTOMER_ORDER_EMAIL_BODY -->
<!-- BEGIN CUSTOMER_ORDER_EMAIL_FOOT --><!-- END CUSTOMER_ORDER_EMAIL_FOOT -->

I have tried swaping the position of the code ut does not work

beholder

Avatar: beholder

2009-07-28 15:52

Garry3005, if you have trouble with this, you will definitely have problem with constructing correct multipart HTML email. I've done this for a customer multiple times, I am very proficient in all this.
I offer paid assistance, or ask opensolution.org guys to help you. If you need so, find my contact info on this forum and write me an email.

Garry3005

No avatar

2009-07-29 23:56

This sends Html email to customer

First instal sendmailtocustomer plugin, Then follow steps above from Makaron to change customer email to html install paypal plugin open orders_print.tpl for editing after the line <!-- BEGIN ORDER_EMAIL_FOOT --><!-- END ORDER_EMAIL_FOOT --> remove all code and replace with code bellow

<!-- Customer Order Email HTML V0.9 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
</head>

<body>
<!-- BEGIN CUSTOMER_ORDER_EMAIL_TITLE -->
$lang[Order_customer_info_title]$aData[iOrder]
<!-- END CUSTOMER_ORDER_EMAIL_TITLE -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_HEAD -->
$aData[sProducts]
<div id="Layer1" style="position:absolute; width:800px; height:115px; z-index:2; left: 100px; top: 50px;">
<table bgcolor="#FFFFCC" cellspacing="0" border="0">
<thead bgcolor="#FFFF99">
<td bgcolor="#FFFF99" colspan="1" align="center">
<img src="http://www.yourdomain.com/path-to-company-logo" width="400" height="50">
</td>
<td colspan="3" height="100" align="center" valign="bottom">
<!-- BEGIN ORDER_PAYPAL -->
<form target="paypal" name="_$aData[iOrder]" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="$config[PayPal_email]" />
<input type="hidden" name="item_name" value="Commande N $aOrder[iOrder]" />
<input type="hidden" name="currency_code" value="$config[currency_symbol]" />
<input type="hidden" name="amount" value="$aData[sOrderSummary]" />
<input type="hidden" name="no_note" value="1" />
<input type="image" src="http://www.yourdoman.com/path-to-paypallogo" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
<!-- END ORDER_PAYPAL -->
</td><tr></tr>
<td height="30" colspan="4"></td><tr></tr>
<td class="name">$lang[Name]</td>
<td class="price"><em>$lang[Price]</em><span>[$config[currency_symbol]]</span>& lt;/td>
<td class="quantity">$lang[Quantity]</td>
<td class="summary"><em>$lang[Summary]</em><span>[$config[currency_symbol]]</span& gt;</td>
</tr>
<td height="10" colspan="4"></td><tr></tr>
</thead>
<!-- END CUSTOMER_ORDER_EMAIL_HEAD -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_LIST -->
<tr>
<td width="450" align="left">|n| $aData[sName]</td>
<td align="right">|n| $aData[sPrice]</td>
<td align="center">|n| $aData[iQuantity]</td>
<td align="right">|n| $aData[sSummary]</td>
</tr><tr></tr>
<!-- END CUSTOMER_ORDER_EMAIL_LIST -->
</table>

<!-- BEGIN CUSTOMER_ORDER_EMAIL_BODY -->
<tbody bgcolor="#6633FF">
<td><font face="Aerial" color="blue">
$aData[sProducts] $aData[sFirstName] $aData[sLastName]<br>
$aData[sCompanyName]<br>
$aData[sStreet]<br>
$aData[sCity] $aData[sZipCode]<br>
$aData[sPhone]<br>
$aData[sEmail]<br><br>
</font></td><tr></tr>
</tbody>
<tr></tr><td colspan="3" align="center">$aData[sCarrierName] ($aData[sPaymentName])</td>
<td align="right"colspan="1"> $aData[sPaymentCarrierPrice]</td><tr><tr></tr>
<td align="right" colspan="1">$lang[Summary_cost]: </td>
<td align="right" colspan="3">$aData[sOrderSummary]</td><tr></tr>
<td colspan="4" height="50"></td><tr></tr>
<td align="center" colspan="4" height="30">CeeDee's Tv, 110 Lowtown, Pudsey, Leeds LS28 9AY Tel: 0113 257 0028</td>

<!-- END CUSTOMER_ORDER_EMAIL_BODY -->

<!-- BEGIN CUSTOMER_ORDER_EMAIL_FOOT -->
<!-- END CUSTOMER_ORDER_EMAIL_FOOT -->
</div>
</body>
</html>

Will give you a basic html email sent to your customer

kalanta

No avatar

2009-07-30 10:49

you need to change function sendEmail not for admin emails only, but for customer emails too.

beholder

Avatar: beholder

2009-07-30 12:32

Garry, this HTML email is no good. It is no multipart email, it will not work correctly in some email clients.

Garry3005

No avatar

2009-07-31 00:20

Kalanta
This does not change emails sent to admin only mail sent to customers

beholder
Its ok to offer a paid service, then turn round and say this html is no good. I fully understand that at the moment its not multipart, and bearing in mind never having had anything to to with sending html emails. Without any help I actually managed to get it to send and display correctly in Outlook Express, Thunderbird 2 and Thunderbird 3 beta 3. At least I am willing to try and share my findings
Garry

beholder

Avatar: beholder

2009-07-31 02:40

Look, Garry, I am only informing you, that your solution is low-quality. Try in Opera 9 with 'prefer HTML' off and prepare for a surprise. You should be glad that you know of this liability. Multipart HTML emails are no easy business, I know that, I was there before where you are now - and right now I am just trying to help out.
My point is that you don't choose email clients of your customers, they do it for themselves. I don't need your money, I request to be paid only if the solution takes significant time. Take your shot at the multipart email template, if it proves impossible, you MAY ask me to help you out commercially.

Pages:
Back to top
about us | contact