osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 

HTML in emails

This is a discussion on HTML in emails within the osCMax v1.7 Discussion forums, part of the osCMax v1.7 Forums category; I'm polishing off the site now, nearly there... However one VITAL necessity is to use HTML e-mails, so I can ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v1.7 Forums > osCMax v1.7 Discussion

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 11-22-2003, 03:46 PM
Anonymous
Guest
 
Posts: n/a
Default HTML in emails

I'm polishing off the site now, nearly there...
However one VITAL necessity is to use HTML e-mails, so I can add properly formatted text etc.
Even the standard order confirmation e-mails have URLs which are listed as plain text, and are not clickable!

I opened includes/classes/email.php and had a gander, it seems it adds a text/plain and text/html subpart!
But it doesn't! I'm getting plain text emails!

What do I set / change to send out HTML emails?
thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #2  
Old 11-22-2003, 03:55 PM
Member
 
Join Date: Sep 2003
Posts: 90
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
warrenthewindmill
Default

try this:

http://forums.oscommerce.com/index.p...p;#entry262186

there are a few other oScommerce threads. I'd try searching there
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #3  
Old 11-24-2003, 03:30 PM
Anonymous
Guest
 
Posts: n/a
Default

If you have the html WYSIWYG use this http://www.oscommerce.com/contributi..._gc_coupon.zip
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #4  
Old 11-25-2003, 07:41 PM
Anonymous
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Anonymous
If you have the html WYSIWYG use this http://www.oscommerce.com/contributi..._gc_coupon.zip
thanks warrenthewindmill!
Just hack the gift voucher scripts? I had those installed... just copy paste and adapt the email scripts using the above??

not a bad suggestion mate, cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #5  
Old 11-26-2003, 01:09 AM
Anonymous
Guest
 
Posts: n/a
Default

Will someone then PLEASE explain the Configuration => E-mail Options => Use MIME HTML when sending emails??
Whatever I set it to, emails with HTML code in them just come up with all the HTML tags showing!

On closer inspection, the MIME type in the email is text/plain!!
I have MS2-MAX so I have the WYSIWYG HTML plugin, as well as the coupon one... but no matter how hard I try, I always get emails with the HTML showing!

Is this a bug in OSCommerce?!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #6  
Old 11-26-2003, 01:23 AM
Anonymous
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Anonymous
Will someone then PLEASE explain the Configuration => E-mail Options => Use MIME HTML when sending emails??
Whatever I set it to, emails with HTML code in them just come up with all the HTML tags showing!

On closer inspection, the MIME type in the email is text/plain!!
I have MS2-MAX so I have the WYSIWYG HTML plugin, as well as the coupon one... but no matter how hard I try, I always get emails with the HTML showing!

Is this a bug in OSCommerce?!
Can someone PLEASE answer??
The other stupid thing that happens is that when the method of sending the emails is set to 'smtp' and not 'sendmail' the 'to' field has the sender's address twice (in hotmail at least)! this caused hotmail to slap the message into 'junkmail'!!!

ironically, hotmail shows the HTML in emails up fine, even if they state text/plain in the MIME type. locally, using an email client, i get HTML tags, as you would expect.

can this thread be passed onto the developers, if it IS a bug?
any ideas / solutions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #7  
Old 11-29-2003, 03:35 AM
Anonymous
Guest
 
Posts: n/a
Default

Well, I've made progress, and now KNOW HOW to make HTML in EMAILS WORK!

Basically just type the HTML content in the appropriate script! the default email sending function in oscommerce automatically strips html code and makes a text/plain version of the email, as well as keeping the formatting for an html version, and adds both to your messages!

catalog/checkout_process.php for the order confirmation email,
admin/orders.php for the order status update emails.

Ofcourse, you have to track down the lines which construct the email message. i may add a contribution soon with ready-made ones, which follow the invoice.php layout closely, whilst containing all the original email order confirmation content, but nicely formatted.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #8  
Old 12-04-2003, 03:17 PM
Anonymous
Guest
 
Posts: n/a
Default

Awesome!
Do have an example from that section of the code? That would help me to not throw html somewhere it will cause a problem

Tom
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #9  
Old 12-05-2003, 09:09 AM
Anonymous
Guest
 
Posts: n/a
Default HTML in emails

Quote:
Originally Posted by Anonymous
Awesome!
Do have an example from that section of the code? That would help me to not throw html somewhere it will cause a problem

Tom
Yeah sure...
I'm sure it can EASILY be adapted for other people's sites, in it's present condition...
At the moment I'm working on adding an option where customers can select if they want HTML or PLAIN TEXT emails.

Be warned, my code WORKS PERFECTLY, but YOU NEED TO CHANGE THE IMAGE REFERENCES.
Also, I've put CSS in there, but a LOT of email clients don't understand CSS.
Hence, I have also hard coded certain lines with traditional HTML (for example, table backgrounds etc.) for maximum portability.

The CSS causes a problem in the stripped plain text version of the email, in the sense that it includes all the CSS.
I'm working on an HTML and PLAIN TEXT version of the emails as we speak.
I've also modified the old code to not show up the () brackets that surround MODEL in the plain text emails if there is no model.

here's the code for catalog/checkout_process.php.... remember, I'm working on a better version at the moment!

Quote:
//added an if statement which determines whether the product has a model description.
//before, an ugly () appeared in the order invoice emails, where a product doesnt belong to a model.
if ($order->products[$i]['model'] != '')
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
else
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

}
$order_total_modules->apply_credit();//ICW ADDED FOR CREDIT CLASS SYSTEM
// lets start with the email confirmation
$email_order = '<head><style type="text/css">' .

'.dataTableHeadingRow { background-color: #8CA2D6; }' .
'.dataTableHeadingContent { font-family: Verdana, Arial, sans-serif; font-size: 10px; color: #ffffff; font-weight: bold; }' .
'.dataTableRow { background-color: #F0F1F1; }' .
'.dataTableRowSelected { background-color: #DEE4E8; }' .
'.dataTableRowOver { background-color: #FFFFFF; cursor: pointer; cursor: hand; }' .
'.dataTableContent { font-family: Verdana, Arial, sans-serif; font-size: 10px; color: #000000; }' .
'.main { font-family: Verdana, Arial, sans-serif; font-size: 12px; }' .

'</style></head>' .
'<html><body background="' . HTTP_SERVER . DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES . 'flowers.jpg" style="background-repeat: no-repeat; background-attachment: fixed; background-position: bottom right;">' .
'<!-- body_text //--><center>' .
'<table border="0" width="700px" cellspacing="0" cellpadding="2">' .
'<tr>' .
'<td><table border="0" width="100%" cellspacing="0" cellpadding="0">'.
'<tr>' .
'<td class="pageHeading" align="left">' .
tep_image(HTTP_SERVER . DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES . 'smallTitle.gif', 'Sunny Kid', '230', '59') .
'</td>' .
'</tr>' .
'</table></td>' .
'</tr>' .
'<tr>' .
'<td><table width="100%" border="0" cellspacing="0" cellpadding="2">' .
'<tr>' .
'<td colspan="2">' . tep_draw_separator() . '</td>' .
'</tr>' .
'<tr>' .
'<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">' .
'<tr>' .
'<td class="main"><b>' . EMAIL_TEXT_BILLING_ADDRESS . '</b></td>' .
'</tr>' .
'<tr>' .
'<td class="main">' . tep_address_label($customer_id, $billto, 0, '', "<BR>") . '</td>' .
'</tr>' .
'</table></td>' .

'<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">' .
'<tr>' .
'<td class="main"><b>' . EMAIL_TEXT_DELIVERY_ADDRESS . '</b></td>' .
'</tr>' .
'<tr>' .
'<td class="main">' . tep_address_label($customer_id, $sendto, 0, '', "<BR>") . '</TD>' .
'</tr>' .
'</table></td>' .
'</tr>' .
'</table></td>' .
'</tr>' .
'<tr>' .
'<td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' .
'</tr>' .
'<tr>' .
'<td class="main">' . EMAIL_TEXT_INVOICE_URL . ' <a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . '">' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) .'</a></td>' .
'</tr>' .
'<tr>' .
'<td><table border="1" width="100%" cellspacing="0" cellpadding="2">' .
'<tr bgcolor=#8CA2D6 class="dataTableHeadingRow">' .
'<td colspan="2" class="dataTableHeadingContent"><font color="#ffffff"><b>' . EMAIL_TEXT_PRODUCTS . '</b></font></td>';

$email_order .= '<td align="right" class="dataTableHeadingContent"><font color="#ffffff"><b>' .
strip_tags($order_totals[sizeof($order_totals) - 1]['title']) . '</b></font></td>' .
'</tr>';

for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$email_order .= ' <tr class="dataTableRow">' .
' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' .
' <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
for ($j = 0; $j < $k; $j++) {
$email_order .= '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
if ($order->products[$i]['attributes'][$j]['price'] != '0') $email_order .= ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
$email_order .= '</i></small></nobr>';
}
}

$email_order .= ' </td>';
// model line removed ' <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>'
$email_order .= ' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>';
$email_order .= ' </tr>';
}
$email_order .= ' </table></tr><tr><td>';

//the totals table
$email_order .= '<table border="0" cellspacing="0" cellpadding="2" align=right>';
for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

$email_order .= '<td class="dataTableContent" align="right" valign="top">' . strip_tags($order_totals[$i]['title']) . '</td>';

$email_order .= '<td class="dataTableContent" align="right" valign="top">';
if ($i == $n - 1){
$email_order .= '<b>' . strip_tags($order_totals[$i]['text']) . '</b></td></tr>';}
else{
$email_order .= strip_tags($order_totals[$i]['text']) . '</td></tr>';}
}
$email_order .= '</table></tr><tr><td class="main">';

//remove the old style invoice /* STORE_NAME . */ "\n" .
/* EMAIL_SEPARATOR . "\n" .
EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
EMAIL_TEXT_INVOICE_URL . ' <a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . '">' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "</a>\n" .
EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
if ($order->info['comments']) {
$email_order .= tep_db_output($order->info['comments']) . "\n\n";
}
$email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
EMAIL_SEPARATOR . "\n" .
$products_ordered .
EMAIL_SEPARATOR . "\n";

for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";
}

if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .
EMAIL_SEPARATOR . "\n" .
tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
}

$email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
EMAIL_SEPARATOR . "\n" .
tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";
*/

$email_order .= '<b>' . EMAIL_TEXT_PAYMENT_METHOD . ':</b> ' . $$payment->title .
'</td></tr><tr><td class="main">';
if (is_object($$payment)) {
/* $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .
EMAIL_SEPARATOR . "\n"; */
$payment_class = $$payment;
// $email_order .= $payment_class->title . "\n\n";
if ($payment_class->email_footer) {
$email_order .= $payment_class->email_footer . '</td></tr></table>';

}
}

This code sits after

Quote:
//------insert customer choosen option eof ----
$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;
and before


Quote:
tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, /*STORE_OWNER*/ STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
good luck and tell me if you want the code for orders.php!!
tell me what you think!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
HTML Emails being sent as plain text or with source showing malcol27 osCMax v1.7 Installation 8 04-25-2005 10:31 PM
No emails being sent swkhost osCMax v1.7 Installation 2 02-20-2005 10:43 AM
Order emails cigarjoe2003 osCMax v1.7 Installation 2 11-25-2004 12:03 AM
How to set CODEPAGE in EMAILS? stando osCMax v1.7 Discussion 0 09-08-2004 08:36 AM
Newsletter / Emails peterb osCommerce 2.2 Modification Help 0 07-01-2003 09:54 AM


All times are GMT -8. The time now is 10:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax