Results 1 to 9 of 9

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 ...

      
  1. #1
    Anonymous
    Guest


    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.

  2. #2
    Member
    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    0


    Default

    try this:

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

    there are a few other oScommerce threads. I'd try searching there

  3. #3
    Anonymous
    Guest


    Default

    If you have the html WYSIWYG use this http://www.oscommerce.com/contributi..._gc_coupon.zip

  4. #4
    Anonymous
    Guest


    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

  5. #5
    Anonymous
    Guest


    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?!

  6. #6
    Anonymous
    Guest


    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?

  7. #7
    Anonymous
    Guest


    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.

  8. #8
    Anonymous
    Guest


    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

  9. #9
    Anonymous
    Guest


    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!

    //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

    //------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


    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!

Similar Threads

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •