mail manager for oscommerce Copyright (c) 2011 Niora http://www.css-oscommerce.com Released under the GNU General Public License */ //get status of mail manager status update email $mail_manager_status_query = tep_db_query("select status, template, htmlcontent, txtcontent from " . TABLE_MM_RESPONSEMAIL . " where mail_id = '3'"); $mail_manager_status = tep_db_fetch_array($mail_manager_status_query); if (isset($mail_manager_status['status']) && $mail_manager_status['status'] == '1') { //retrieve html and txt headers $header_query = tep_db_query("select htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $mail_manager_status['template'] . "'"); $header = tep_db_fetch_array($header_query); //build email $output_content_html = $header['htmlheader'] . $mail_manager_status['htmlcontent'] . $header['htmlfooter']; $output_content_txt = $header['txtheader'] . $mail_manager_status['txtcontent'] . $header['txtfooter']; // define subject $output_subject = EMAIL_PASSWORD_RESET_SUBJECT; //define values for placeholder variables $firstname = $check_customer['customers_firstname']; $lastname = $check_customer['customers_lastname']; $newpwandmsg = sprintf(EMAIL_PASSWORD_RESET_BODY, $reset_key_url); //define placeholders. $placeholders = array('$storeurl', '$storename', '$storeemail', '$customerfirstname', '$customerlastname', '$customeremail', '$emailsubject', '$newpwandmsg'); $values = array(HTTP_CATALOG_SERVER, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $firstname, $lastname, $email_address, EMAIL_PASSWORD_RESET_SUBJECT, $newpwandmsg); $output_content_html = str_replace($placeholders, $values, $output_content_html); $output_content_txt = str_replace($placeholders, $values, $output_content_txt); //send email tep_mm_sendmail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $email_address, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $output_subject, $output_content_html, $output_content_txt); //if mail manager status update email 'inactive', or value=0, process normally via oscommerce } else { tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $email_address, EMAIL_PASSWORD_RESET_SUBJECT, sprintf(EMAIL_PASSWORD_RESET_BODY, $reset_key_url), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); }
} } else { $mmgreet = sprintf(EMAIL_GREET_NONE, $firstname); } //get status of mail manager create account email $mail_manager_status_query = tep_db_query("select status, template, htmlcontent, txtcontent from " . TABLE_MM_RESPONSEMAIL . " where mail_id = '0'"); $mail_manager_status = tep_db_fetch_array($mail_manager_status_query); if (isset($mail_manager_status['status']) && $mail_manager_status['status'] == '1') { //retrieve html and txt headers $header_query = tep_db_query("select htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $mail_manager_status['template'] . "'"); $header = tep_db_fetch_array($header_query); //build email $output_content_html = $header['htmlheader'] . $mail_manager_status['htmlcontent'] . $header['htmlfooter']; $output_content_txt = $header['txtheader'] . $mail_manager_status['txtcontent'] . $header['txtfooter']; $output_subject = EMAIL_SUBJECT; //define values for placeholder variables $mmwelcome = EMAIL_WELCOME; $mmtext = EMAIL_TEXT; $mmcontact = EMAIL_CONTACT; $mmwarning = EMAIL_WARNING; //define placeholders $placeholders = array('$storeurl', '$storename', '$storeemail', '$customername', '$mmgreet', '$mmwelcome', '$mmtext', '$mmcontact', '$mmwarning'); $values = array(HTTP_SERVER, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $name, $mmgreet, EMAIL_WELCOME, EMAIL_TEXT, EMAIL_CONTACT, EMAIL_WARNING); $output_content_html = str_replace($placeholders, $values, $output_content_html); $output_content_txt = str_replace($placeholders, $values, $output_content_txt); //send email tep_mm_sendmail($name, $email_address, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $output_subject, $output_content_html, $output_content_txt); //if mail manager status update email is 'inactive' process normally via oscommerce } else { tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); }
} //retrieve html and txt headers $header_query = tep_db_query("select htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $mail_manager_status['template'] . "'"); $header = tep_db_fetch_array($header_query); //build email $output_content_html = $header['htmlheader'] . $mail_manager_status['htmlcontent'] . $header['htmlfooter']; $output_content_txt = $header['txtheader'] . $mail_manager_status['txtcontent'] . $header['txtfooter']; $output_subject = EMAIL_TEXT_CONFIRM . STORE_NAME; //define values for placeholder variables $order_no = EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id; $order_date = EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG); // PWA Integration: Select Invoice URL if customer is a guest if (tep_session_is_registered('customer_is_guest')) { $invoice_url = EMAIL_WARNING . "\n\n"; } else { $invoice_url = EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false); } $delivery_address = tep_address_label($customer_id, $sendto, 0, '', '<br />'); $billing_address = tep_address_label($customer_id, $billto, 0, '', '<br />'); $order_comments = $order->info['comments']; $paymentmethod = $order->info['payment_method']; $ccardtype = $order->info['cc_type']; $payment_class = $payment_class->email_footer; //define placeholders $placeholders = array('$storeurl', '$storename', '$storeemail', '$separator', '$orderno', '$orderdate', '$invoiceurl', '$productsorderedhead', '$productsordered', '$deliveryaddresshead', '$deliveryaddress', '$billingaddresshead', '$billingaddress', '$paymethodhead', '$paymentmethod', '$ccardtype', '$ordercomments', '$totaltext', 'subtotaltext', '$ordertotal'); $values = array(HTTP_SERVER, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SEPARATOR, $order_no, $order_date, $invoice_url, EMAIL_TEXT_PRODUCTS, $products_ordered, EMAIL_TEXT_DELIVERY_ADDRESS, $delivery_address, EMAIL_TEXT_BILLING_ADDRESS, $billing_address, EMAIL_TEXT_PAYMENT_METHOD, $paymentmethod, $ccardtype, $order_comments, EMAIL_TEXT_TOTAL, EMAIL_TEXT_SUBTOTAL, $mm_ordertotal); $output_content_html = str_replace($placeholders, $values, $output_content_html); $output_content_txt = str_replace($placeholders, $values, $output_content_txt); //send email tep_mm_sendmail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $output_subject, $output_content_html, strip_tags($output_content_txt));
Released under the GNU General Public License */ require 'includes/application_top.php'; $search = isset($HTTP_GET_VARS['search_customers']) ? $HTTP_GET_VARS['search_customers'] : ''; $action = isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''; if ($action == 'send_email_to_user' && isset($HTTP_POST_VARS['customers_email_address']) && !isset($HTTP_POST_VARS['back_x'])) { $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . $HTTP_POST_VARS['customers_email_address'] . "'"); $mail = tep_db_fetch_array($mail_query); $template_name = tep_db_prepare_input($HTTP_POST_VARS['template']); $template_query = tep_db_query("select title, htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $template_name . "'"); $template = tep_db_fetch_array($template_query); $from = tep_db_prepare_input($HTTP_POST_VARS['from']); $output_subject = tep_db_prepare_input($HTTP_POST_VARS['subject']); $output_content_html = $template['htmlheader'] . tep_db_prepare_input($HTTP_POST_VARS['message'] . $template['htmlfooter']); $output_content_txt = $template['txtheader'] . tep_db_prepare_input($HTTP_POST_VARS['message'] . $template['txtfooter']); tep_mm_sendmail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], STORE_OWNER, $from, $output_subject, $output_content_html, $output_content_txt); tep_redirect(tep_href_link(FILENAME_MM_EMAIL, 'mail_sent_to=' . urlencode($mail_sent_to))); } if ($action == 'preview' && !isset($HTTP_POST_VARS['customers_email_address'])) { $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error'); } if (isset($HTTP_GET_VARS['mail_sent_to'])) { $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'success'); } require DIR_WS_INCLUDES . 'template_top.php'; ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE;
<?php } elseif ($action == 'test') { $nID = tep_db_prepare_input($HTTP_GET_VARS['nID']); $mail_query = tep_db_query("select title, htmlcontent, txtcontent, template from " . TABLE_MM_RESPONSEMAIL . " where mail_id = '" . (int) $nID . "'"); $mail = tep_db_fetch_array($mail_query); $template_name = $mail['template']; $template_query = tep_db_query("select title, htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $template_name . "'"); $template = tep_db_fetch_array($template_query); $output_subject = $mail[title]; $output_content_html = $template['htmlheader'] . $mail['htmlcontent'] . $template['htmlfooter']; $output_content_txt = $template['txtheader'] . $mail['txtcontent'] . $template['txtfooter']; $placeholders = array('$storeurl', '$storeowner', '$storeemail'); $values = array(HTTP_CATALOG_SERVER, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $output_content_html = str_replace($placeholders, $values, $output_content_html); tep_mm_sendmail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $output_subject, $output_content_html, $output_content_txt); ?> <tr> <td><em><?php echo $mail['title'] . '</em> sent to ' . STORE_OWNER_EMAIL_ADDRESS; ?> </td></tr> <tr> <td><?php echo '<a href="' . tep_href_link(FILENAME_MM_RESPONSEMAIL, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK); ?> </a></td></tr> <?php } else { ?>
Released under the GNU General Public License */ //get status of mail manager status update email $mail_manager_status_query = tep_db_query("select status, template, htmlcontent, txtcontent from " . TABLE_MM_RESPONSEMAIL . " where mail_id = '2'"); $mail_manager_status = tep_db_fetch_array($mail_manager_status_query); if (isset($mail_manager_status['status']) && $mail_manager_status['status'] == '1') { //retrieve html and txt headers $header_query = tep_db_query("select htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $mail_manager_status['template'] . "'"); $header = tep_db_fetch_array($header_query); //build email $output_content_html = $header['htmlheader'] . $mail_manager_status['htmlcontent'] . $header['htmlfooter']; $output_content_txt = $header['txtheader'] . $mail_manager_status['txtcontent'] . $header['txtfooter']; $output_subject = EMAIL_TEXT_SUBJECT; //define values for placeholder variables $order_no = EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID; $order_date = EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']); $status_newhtml = sprintf(EMAIL_HTML_STATUS_UPDATE, $orders_status_array[$status]); $status_newtxt = sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]); $comments = $notify_comments; $invoice_url = EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL'); //define placeholders $placeholders = array('$storeurl', '$storename', '$storeemail', '$customername', '$customeremail', '$emailsubject', '$orderno', '$orderdate', '$statusnewhtml', '$statusnewtxt', '$comments', '$invoiceurl', '$separator'); $values = array(HTTP_CATALOG_SERVER, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $name, $email_address, EMAIL_TEXT_SUBJECT, $order_no, $order_date, $status_newhtml, $status_newtxt, $comments, $invoice_url, EMAIL_SEPARATOR); $output_content_html = str_replace($placeholders, $values, $output_content_html); $output_content_txt = str_replace($placeholders, $values, $output_content_txt); //send email tep_mm_sendmail($check_status['customers_name'], $check_status['customers_email_address'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $output_subject, $output_content_html, $output_content_txt); //if mail manager status update email 'inactive', or value=0, process normally via oscommerce } else { tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); }
$output_content_html = $template['htmlheader'] . $newsletter['content'] . $template['htmlfooter']; $output_content_txt = $template['txtheader'] . $newsletter['txtcontent'] . $template['txtfooter']; // placeholders $placeholders = array('storeurl', 'storeowner', 'storeemail'); $values = array(HTTP_SERVER, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $output_content_html = str_replace($placeholders, $values, $output_content_html); // get customer selection criteria and additional content from module require DIR_WS_MODULES . 'mail_manager/' . $newsletter['module'] . substr($PHP_SELF, strrpos($PHP_SELF, '.')); if ($additional_htmlcontent != NULL) { //add additional_htmlcontent and additional_txtcontent, if it exists. from selected module. Module files located in admin/includes/mail_manager. $output_content_html = $template['htmlheader'] . $newsletter['content'] . $additional_htmlcontent . $template['htmlfooter']; $output_content_txt = $template['txtheader'] . $newsletter['txtcontent'] . strip_tags($additional_txtcontent) . $template['txtfooter']; } //start mailing loop if ($mail['mmstatus'] == '0') { tep_mm_sendmail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $newsletter['subject'], $output_content_html, $output_content_txt); $email = $mail['customers_email_address']; tep_db_query("UPDATE " . TABLE_CUSTOMERS . " SET mmstatus = '9' WHERE customers_email_address ='" . $email . "' Limit 1"); //Create/update log file of sent emails. $log_file_id = tep_session_id(); //Using tep_session_id to make the file name unique to this mailing. It's unlikely that someone would send the same newsletter while still logged in with the same session_id. $email_name = $mail['first_name'] . ' ' . $mail['last_name']; $date_time = date("D, d M Y g:i a"); //Does the log file already exist? $log_file_check = tep_db_input($newsletter_id) . '_' . $log_file_id . '.html'; if (!file_exists($log_file_check)) { $log_data = ' <table> <tr> <td colspan="3"><h1>Log File of Sent Emails for Newsletter ID #' . tep_db_input($newsletter_id) . '</h1></td> </tr>
$mail_manager_status = tep_db_fetch_array($mail_manager_status_query); if (isset($mail_manager_status['status']) && $mail_manager_status['status'] == '1') { //retrieve html and txt headers $header_query = tep_db_query("select htmlheader, htmlfooter, txtheader, txtfooter from " . TABLE_MM_TEMPLATES . " where title = '" . $mail_manager_status['template'] . "'"); $header = tep_db_fetch_array($header_query); //build email $output_content_html = $header['htmlheader'] . $mail_manager_status['htmlcontent'] . $header['htmlfooter']; $output_content_txt = $header['txtheader'] . $mail_manager_status['txtcontent'] . $header['txtfooter']; // define subject $output_subject = $from_name . ' ' . TEXT_RECOMMEND . ' ' . $product_info['products_name'] . ' ' . TEXT_FROM . ' ' . STORE_NAME; //See catalog/includes/configure to construct the correct value of $image_urlfix if (DIR_WS_HTTP_CATALOG == NULL) { $image_urlfix = HTTP_SERVER; } else { $image_urlfix = HTTP_SERVER . DIR_WS_HTTP_CATALOG; } //define values for placeholder variables $product_link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL', false); $product_image = tep_image($image_urlfix . DIR_WS_IMAGES . $product_info['products_image_med'], $product_info['products_name'], '', '', ''); $product_name = $product_info['products_name']; //define placeholders $placeholders = array('$storeurl', '$storename', '$storeemail', '$toname', '$fromname', '$product', '$link', '$image', '$message'); $values = array(HTTP_SERVER, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $to_name, $from_name, $product_name, $product_link, $product_image, $message); $output_content_html = str_replace($placeholders, $values, $output_content_html); $output_content_txt = str_replace($placeholders, $values, $output_content_txt); //send email tep_mm_sendmail($to_name, $to_email_address, $from_name, $from_email_address, $output_subject, $output_content_html, $output_content_txt); //if mail manager status update email 'inactive', or value=0, process normally via oscommerce } else { tep_mail($to_name, $to_email_address, $email_subject, $email_body, $from_name, $from_email_address); }