$tpl['info'] = $order->info; $tpl['customer'] = $order->customer; $tpl['customer']['password'] = '******'; list($tpl['customer']['firstname'], $tpl['customer']['lastname']) = explode(' ', $tpl['customer']['name']); $tpl['date'] = strftime(DATE_FORMAT_LONG); $tpl['address'] = array(shipping => array(text => tep_address_format($order->delivery['format_id'], $order->delivery, 0, '', "\n"), html => tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', "\n")), billing => array(text => tep_address_format($order->billing['format_id'], $order->billing, 0, '', "\n"), html => tep_address_format($order->billing['format_id'], $order->billing, 1, '', "\n"))); $tpl['products_ordered'] = array('text' => $products_ordered, 'html' => $products_ordered_html); $tpl['payment'] = array(title => $order->info['payment_method'], subtotal => '$' . number_format($order->info['subtotal'], 2), total => '$' . number_format($order->info['total'], 2), order_total_label => array(text => join("\n", $ot_label_text), html => "<table width=100%>\n" . join("\n", $ot_label_html) . "</table>"), cc_type => isset($order->info['cc_type']) ? $order->info['cc_type'] : '', cc_number => isset($order->info['cc_number']) ? str_repeat('*', max(strlen($order->info['cc_number']) - 4, 0)) . substr($order->info['cc_number'], -4, 4) : ''); $tpl['ship_info'] = $ship_info[$ship_method]; $tpl['ship_info']['service_eta'] = 3; $tpl['ship_info']['method'] = preg_replace('/^.*?_/', '', $order->info['shipping_method']); $tpl['comments'] = !empty($order->info['comments']) ? $order->info['comments'] : ''; if (!empty($tpl['order_id'])) { require_once DIR_WS_FUNCTIONS . 'email_now.php'; $extra_emails = SEND_EXTRA_ORDER_EMAILS_TO != '' ? explode(',', SEND_EXTRA_ORDER_EMAILS_TO) : NULL; email_now('checkout_confirm', $tpl, $extra_emails); } else { tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, 'Order email attempted with no order data from IP ' . $_SERVER['REMOTE_ADDR'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } $messageStack->add_session('An email order confirmation has been sent.', 'success'); $messageStack->add('An email order confirmation has been sent.', 'success'); } else { // # POST['send_confirmation'] is not set $messageStack->add_session('You have opted not to send an order confirmation email.', 'warning'); $messageStack->add('You have opted not to send an order confirmation email.', 'warning'); } // # Update Message Stack if ($order_updated == true) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); $messageStack->add(SUCCESS_ORDER_UPDATED, 'success'); } elseif ($customer_notified == 1) {
function email_by_event($user_id, $contact_id, $template_name, $email_from, $additional_message = '') { $jky_user = db_get_row('JKY_Users', 'id = ' . $user_id); $contact = db_get_row('Contacts', 'id = ' . $contact_id); $to_name = $contact['full_name']; $to_email = $contact['email']; $cc_name = ''; $cc_email = ''; $template = db_get_row('Templates', 'template_name = "' . $template_name . '"'); $subject = revert_entities($template['template_subject']); $body = revert_entities($template['template_body']); $names = explode(';', get_control_value('System Keys', $email_from)); $from_name = $names[0]; $from_email = $names[1]; $server_name = SERVER_NAME; if (strpos($server_name, '8100') > 0) { $server_name = 'http://' . get_control_value('Servers Host', SERVER_NUMBER) . ':8100/'; } $search = array(); $replace = array(); $search[] = '+'; $replace[] = ' '; $search[] = '{SERVER_NAME}'; $replace[] = $server_name; $search[] = '{COMPANY_LOGO}'; $replace[] = COMPANY_LOGO; $search[] = '{SUPPORT_NAME}'; $replace[] = $from_name; $search[] = '{USER_EMAIL}'; $replace[] = $contact['email']; $search[] = '{USER_NAME}'; $replace[] = $contact['full_name']; $search[] = '{USER_KEY}'; $replace[] = $jky_user['user_key']; $subject = str_replace($search, $replace, $subject); $body = str_replace($search, $replace, $body); /* $data = array(); if( is_session( 'user_id' )) $data[ 'sent_from' ] = get_session( 'user_id' ); $data[ 'sent_to' ] = $user_id; $data[ 'sent_at' ] = get_time(); $data[ 'to_email' ] = $user[ 'user_email' ]; $data[ 'to_name' ] = $user[ 'full_name' ]; $data[ 'cc_email' ] = ''; $data[ 'cc_name' ] = ''; $data[ 'controller' ] = $template[ 'controller' ]; $data[ 'action' ] = $template[ 'action' ]; $data[ 'subject' ] = str_replace( $search, $replace, $template[ 'subject' ]); $data[ 'body' ] = str_replace( $search, $replace, $template[ 'body' ]); $data[ 'body' ] .= '<br><br>' . $additional_message; $model = MODEL . 'Emails'; $Emails = new $model(); $Emails->insert( $data ); */ $return = email_now($from_email, $from_name, $to_email, $to_name, $cc_email, $cc_name, $subject, $body); return $to_email; }
private function send_receipt() { $receive_id = get_request('receive_id'); $template_name = get_request('template_name'); $email_from = 'Email From System'; $receive = db_get_row('Receives', 'id = ' . $receive_id); $services = db_get_rows('Services', 'receive_id = ' . $receive_id); $helper_names = ''; foreach ($services as $service) { $user = db_get_row('Contacts', 'id = ' . $service['user_id']); $helper_names .= '<br>' . $user['full_name']; } $to_name = $receive['full_name']; $to_email = $receive['email']; $cc_name = ''; $cc_email = ''; $template = db_get_row('Templates', 'template_name = "' . $template_name . '"'); $subject = revert_entities($template['template_subject']); $body = revert_entities($template['template_body']); $names = explode(';', get_control_value('System Keys', $email_from)); $from_name = $names[0]; $from_email = $names[1]; $search = array(); $replace = array(); $search[] = '+'; $replace[] = ' '; $search[] = '{SERVER_NAME}'; $replace[] = SERVER_NAME; $search[] = '{FULL_NAME}'; $replace[] = $receive['full_name']; $search[] = '{STREET}'; $replace[] = $receive['street']; $search[] = '{CITY}'; $replace[] = $receive['city']; $search[] = '{ZIP}'; $replace[] = $receive['zip']; $search[] = '{STATE}'; $replace[] = $receive['state']; $search[] = '{RECEIVE_ON}'; $replace[] = format_date($receive['receive_on']); $search[] = '{RECEIVE_AMOUNT}'; $replace[] = $receive['receive_amount']; $search[] = '{EVENT_NAME}'; $replace[] = get_session('event_name'); $search[] = '{HELPER_NAMES}'; $replace[] = $helper_names; $subject = str_replace($search, $replace, $subject); $body = str_replace($search, $replace, $body); email_now($from_email, $from_name, $to_email, $to_name, $cc_email, $cc_name, $subject, $body); $return = array(); $return['status'] = 'ok'; $return['message'] = 'Email sent out, the template: ' . $template_name; echo json_encode($return); }
$tpl = array(); $tpl['config'] = array(store_name => STORE_NAME, store_owner_email_address => STORE_OWNER_EMAIL_ADDRESS, http_server => HTTP_SERVER); $tpl['link'] = array(account_history => tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false), account => tep_href_link('account.php'), tell_a_friend => tep_href_link('tell_a_friend.php')); $tpl['order_id'] = $insert_id; $tpl['info'] = $order->info; $tpl['customer'] = $order->customer; $tpl['customer']['password'] = isset($_SESSION['customer_password']) ? $_SESSION['customer_password'] : $HTTP_POST_VARS['password']; $tpl['date'] = strftime(DATE_FORMAT_LONG); $tpl['address'] = array(shipping => array(text => tep_address_format($order->delivery['format_id'], $order->delivery, 0, '', "\n"), html => tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', "\n")), billing => array(text => tep_address_format($order->billing['format_id'], $order->billing, 0, '', "\n"), html => tep_address_format($order->billing['format_id'], $order->billing, 1, '', "\n"))); $tpl['products_ordered'] = $products_ordered; $payment_class = ${$payment}; $tpl['payment'] = array(title => $payment_class->title, subtotal => '$' . number_format($order->info['subtotal'], 2), total => '$' . number_format($order->info['total'], 2), order_total_label => array(text => join("\n", $ot_label_text), html => "<table>\n" . join("\n", $ot_label_html) . "</table>"), cc_type => isset($order->info['cc_type']) ? $order->info['cc_type'] : '', cc_number => isset($order->info['cc_number']) ? str_repeat('*', max(strlen($order->info['cc_number']) - 4, 0)) . substr($order->info['cc_number'], -4, 4) : ''); $tpl['ship_info'] = $ship_info[$ship[0]]; $tpl['ship_info']['service_eta'] = $service_eta; require_once DIR_WS_FUNCTIONS . 'email_now.php'; email_now('checkout_confirm', $tpl, SEND_EXTRA_ORDER_EMAILS_TO != '' ? split(',', SEND_EXTRA_ORDER_EMAILS_TO) : NULL); } else { 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"; }