Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HTML Emails


mes

Recommended Posts

Hey guys I would like to change the boring old text emails you get with OS to HTML emails, incorporating graphics etc..

 

Is this possible? and how is it done, does it need a contribution.

 

Thanks

Link to comment
Share on other sites

Hey guys I would like to change the boring old text emails you get with OS to HTML emails, incorporating graphics etc..

 

Is this possible? and how is it done, does it need a contribution.

 

Thanks

 

admin -> email options

Treasurer MFC

Link to comment
Share on other sites

Thanks Boxtel but i figured that.

 

It is still too restrictive. You cant really position graphics and change background colours etc. All you can do is change text colour etc.

 

or am I wrong there?

 

any ideas guys..

 

thanks

 

mes

Link to comment
Share on other sites

Thanks Boxtel but i figured that.

 

It is still too restrictive. You cant really position graphics and change background colours etc. All you can do is change text colour etc.

 

or am I wrong there?

 

any ideas guys..

 

thanks

 

mes

 

 

you can send whatever html you can put together.

Treasurer MFC

Link to comment
Share on other sites

I tried the same thing- went to Admin, then Config and changed the value to "true" so that emails could be sent in html format.

 

I then went to "send email" under the "tools" menu option, and entered html code in the text box.

 

However, the email was in plain text- the tags were visible and the text was not formatted.

 

Any ideas?

 

Thank you kindly for any advice you can give.

Link to comment
Share on other sites

I tried the same thing- went to Admin, then Config and changed the value to "true" so that emails could be sent in html format.

 

I then went to "send email" under the "tools" menu option, and entered html code in the text box.

 

However, the email was in plain text- the tags were visible and the text was not formatted.

 

Any ideas?

 

Thank you kindly for any advice you can give.

 

 

well, that send function is not mother finest:

 

in admin/mail.php you see this code :

 

 

while ($mail = tep_db_fetch_array($mail_query)) {

$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);

}

 

 

change that to this :

 

while ($mail = tep_db_fetch_array($mail_query)) {

 

tep_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], $subject, $message , STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

// $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);

}

Treasurer MFC

Link to comment
Share on other sites

Does this stuff apply to the Welcome Email and the Order emails sent out after purchase? :blink:

 

I've been trying to figure out how to make them HTML for months now. I have the layout I want coded in HTML but can't figure out where to place the HTML code.

My Favorite Quote from a movie.

 

Question: How do you know women sooo well?

 

Answer: I think of a man, then take away reason and accountability.

Link to comment
Share on other sites

Does this stuff apply to the Welcome Email and the Order emails sent out after purchase? :blink:

 

I've been trying to figure out how to make them HTML for months now. I have the layout I want coded in HTML but can't figure out where to place the HTML code.

 

 

the frontend already uses tep_mail().

 

the order confirmation email is constructed in checkout process.

 

this code constructs the email content and sends it out:

 

 

// lets start with the email confirmation

$email_order = STORE_NAME . "\n" .

EMAIL_SEPARATOR . "\n" .

EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .

EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\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";

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 . "\n\n";

}

}

tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

// send emails to other people

if (SEND_EXTRA_ORDER_EMAILS_TO != '') {

tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

}

 

you will have to wrap that in html tags.

Treasurer MFC

Link to comment
Share on other sites

the frontend already uses tep_mail().

 

the order confirmation email is constructed in checkout process.

 

this code constructs the email content and sends it out:

// lets start with the email confirmation

  $email_order = STORE_NAME . "\n" .

                EMAIL_SEPARATOR . "\n" .

                EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .

                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\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";

  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 . "\n\n";

    }

  }

  tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

// send emails to other people

  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {

    tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

  }

 

you will have to wrap that in html tags.

 

So all I have to do is Insert My HTML Code around this?

 

And place codes like:

 

$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";

 

in my HTML Code where I want it to appear, Right?? :blink:

 

One more question, where is this file located and what is it named?

 

OK, that was 2 questions :blush:

My Favorite Quote from a movie.

 

Question: How do you know women sooo well?

 

Answer: I think of a man, then take away reason and accountability.

Link to comment
Share on other sites

So all I have to do is Insert My HTML Code around this?

 

And place codes like:

 

$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";

 

in my HTML Code where I want it to appear, Right?? :blink:

 

One more question, where is this file located and what is it named?

 

OK, that was 2 questions  :blush:

 

 

checkout_process.php.

 

just add normal html like:

 

// order confirmation email

$email_separator = '_______________________________________________________________________' . "\n";

 

$email_order =

'<table width="100%" cellspacing="0" cellpadding="0"><tr><td style="font-size: 12px">';

 

if (tep_session_is_registered('noaccount')) {

$email_order .= EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\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_separator . EMAIL_TEXT_PRODUCTS . "\n" .

$products_ordered .

$email_separator;

etc.....

Treasurer MFC

Link to comment
Share on other sites

checkout_process.php.

 

just add normal html like:

 

// order confirmation email

$email_separator = '_______________________________________________________________________' . "\n";

 

$email_order =

'<table width="100%" cellspacing="0" cellpadding="0"><tr><td style="font-size: 12px">';

 

if (tep_session_is_registered('noaccount')) {

  $email_order .= EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\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_separator . EMAIL_TEXT_PRODUCTS . "\n" .

                  $products_ordered .

                  $email_separator;

etc.....

 

Thanks amanda :thumbsup:

 

I'll give it a try, but I might still need some help with this :blush:

My Favorite Quote from a movie.

 

Question: How do you know women sooo well?

 

Answer: I think of a man, then take away reason and accountability.

Link to comment
Share on other sites

Thanks amanda :thumbsup:

 

I'll give it a try, but I might still need some help with this :blush:

 

 

I simply use some includes which makes the editing a little easier.

 

in checkout process I use :

 

// lets start with the email confirmation

include(DIR_WS_INCLUDES . 'order_confirmation_email.php');

 

just before this code :

 

if (USE_EMAIL_QUEUE == 'true') {

tep_store_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT . ' #' . $insert_id , $email_content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

} else {

tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT . ' #' . $insert_id , $email_content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

}

 

 

then in order_confirmation_email.php I use :

 

<?php

// order confirmation email

$email_separator = '_______________________________________________________________________' . "\n";

 

$email_order = '<table width="100%" cellspacing="0" cellpadding="0">';

$email_order .= '<tr>';

$email_order .= '<td style="font-size: 12px">';

 

if (tep_session_is_registered('noaccount')) {

$email_order .= EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\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_separator . EMAIL_TEXT_PRODUCTS . "\n" .

$products_ordered .

$email_separator;

} else {

$email_order .= 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) . '>' . EMAIL_TEXT_INVOICE_LINK . '</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_separator . EMAIL_TEXT_PRODUCTS . "\n" .

$products_ordered .

$email_separator;

}

 

for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

$email_order .= '<strong>' . strip_tags($order_totals[$i]['title']) . '</strong> ' . strip_tags($order_totals[$i]['text']) . "\n";

}

 

if ($order->content_type != 'virtual') {

$email_order .= $email_separator . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .

tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";

}

 

$email_order .= $email_separator . EMAIL_TEXT_BILLING_ADDRESS . "\n" .

tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";

 

if (is_object($$payment)) {

$email_order .= $email_separator . EMAIL_TEXT_PAYMENT_METHOD . "\n";

 

$payment_class = $$payment;

$email_order .= $payment_class->title . "\n\n";

if ($payment_class->email_footer) {

$email_order .= $payment_class->email_footer . "\n\n";

}

$email_order .= $email_separator . EMAIL_TEXT_SIGNATURE . "\n\n";

 

}

 

$email_order .= '</td>';

$email_order .= '</tr>';

$email_order .= '</table>';

 

// wrapping it up

include(DIR_WS_INCLUDES . 'email_html_header.php');

$email_content .= $email_order;

include(DIR_WS_INCLUDES . 'email_html_footer.php');

?>

 

and in email_html_header I use :

 

<?php

$email_content = '<html>';

$email_content .= '<head>';

$email_content .= '</head>';

$email_content .= '<body style="width: 100%; padding: 0px; margin: 0px; ">';

$email_content .= '<div style="width: 100%; text-align: left; direction: ltr; padding: 0px; margin: 0px;">';

$email_content .= '<a href="http://www.crystallight.com.tw/">';

$email_content .= '<img style="padding: 0px;" src="http://www.crystallight.com.tw/images/banner_blue2.jpg" alt="Crystal Light Centrum" border="0">';

$email_content .= '</a>';

$email_content .= '</div>';

$email_content .= '<div lang="en" DIR="ltr" style="padding: 10px; background-color: #effaff; direction: ltr; font-family: arial; font-size: 10px;">';

?>

 

and in email_html_footer I use :

 

<?php

$email_content .= '</div>';

$email_content .= '</body>';

$email_content .= '</html>';

?>

 

then I change the send to use $email_content instead of $email_order as shown above.

 

that way you can re-use the header and footer as includes for all other html emails.

Treasurer MFC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...