function tep_mail_no_triptag($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $htm = false, $attachment = '', $file_name = '', $header = '') { if (SEND_EMAILS != 'true') { return false; } // Instantiate a new mail object $message = new email(array('X-Mailer: osC mailer')); // Build the text version $message->add_html($email_text, '', DIR_FS_CATALOG . DIR_WS_IMAGES); if (is_array($attachment)) { foreach ($attachment as $add) { // if(!empty($add)){ // if(strlen($add)>255){ $file_content = $add; // }else{ // $file_content=$message->get_file($add); // } $message->add_attachment($file_content, $file_name); // } } } // Send message $message->build_message(); $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject, $header, '-f' . STORE_OWNER_EMAIL_ADDRESS); }
function zen_mail($to_name, $to_address, $email_subject, $email_text, $from_email_name, $from_email_address, $block = array(), $module = 'default', $attachments_list = '') { global $db, $messageStack; if (SEND_EMAILS != 'true') { return false; } // if sending email is disabled in Admin, just exit if (!zen_not_null($email_text) && !zen_not_null($block['EMAIL_MESSAGE_HTML'])) { return false; } // if no text or html-msg supplied, exit // Parse "from" addresses for "name" <*****@*****.**> structure, and supply name/address info from it. if (eregi(" *([^<]*) *<([^>]*)> *", $from_email_address, $regs)) { $from_email_name = trim($regs[1]); $from_email_address = $regs[2]; } // if email name is same as email address, use the Store Name as the senders 'Name' if ($from_email_name == $from_email_address) { $from_email_name = STORE_NAME; } // loop thru multiple email recipients if more than one listed --- (esp for the admin's "Extra" emails)... foreach (explode(',', $to_address) as $key => $value) { if (eregi(" *([^<]*) *<([^>]*)> *", $value, $regs)) { $to_name = str_replace('"', '', trim($regs[1])); $to_email_address = $regs[2]; } elseif (eregi(" *([^ ]*) *", $value, $regs)) { $to_email_address = trim($regs[1]); } if (!isset($to_email_address)) { $to_email_address = $to_address; } //if not more than one, just use the main one. //define some additional html message blocks available to templates, then build the html portion. if ($block['EMAIL_TO_NAME'] == '') { $block['EMAIL_TO_NAME'] = $to_name; } if ($block['EMAIL_TO_ADDRESS'] == '') { $block['EMAIL_TO_ADDRESS'] = $to_email_address; } if ($block['EMAIL_SUBJECT'] == '') { $block['EMAIL_SUBJECT'] = $email_subject; } if ($block['EMAIL_FROM_NAME'] == '') { $block['EMAIL_FROM_NAME'] = $from_email_name; } if ($block['EMAIL_FROM_ADDRESS'] == '') { $block['EMAIL_FROM_ADDRESS'] = $from_email_address; } $email_html = zen_build_html_email_from_template($module, $block); // if ($attachments_list == '') $attachments_list= array(); // Instantiate a new mail object $message = new email(array('X-Mailer: Zen Cart Mailer')); // bof: body of the email clean-up // clean up & and && from email text while (strstr($email_text, '&&')) { $email_text = str_replace('&&', '&', $email_text); } while (strstr($email_text, '&')) { $email_text = str_replace('&', '&', $email_text); } while (strstr($email_text, '&&')) { $email_text = str_replace('&&', '&', $email_text); } // clean up money € to e while (strstr($email_text, '€')) { $email_text = str_replace('€', 'e', $email_text); } // fix double quotes while (strstr($email_text, '"')) { $email_text = str_replace('"', '"', $email_text); } // fix slashes $email_text = stripslashes($email_text); $email_html = stripslashes($email_html); // eof: body of the email clean-up //determine customer's email preference type: HTML or TEXT-ONLY (HTML assumed if not specified) $customers_email_format_read = $db->Execute("select customers_email_format from " . TABLE_CUSTOMERS . " where customers_email_address= '" . $to_email_address . "'"); $customers_email_format = $customers_email_format_read->fields['customers_email_format']; if ($customers_email_format == 'NONE' || $customers_email_format == 'OUT') { return; } //if requested no mail, then don't send. if ($customers_email_format == 'HTML') { $customers_email_format = 'HTML'; } // if they opted-in to HTML messages, then send HTML format //determine what format to send messages in if this is an "extra"/admin-copy email: if (ADMIN_EXTRA_EMAIL_FORMAT == 'TEXT' && substr($module, -6) == '_extra') { $email_html = ''; // just blank out the html portion if admin has selected text-only } // Build the email based on whether customer has selected HTML or TEXT, and whether we have supplied HTML or TEXT-only components if (!zen_not_null($email_text)) { $text = str_replace('<br[[:space:]]*/?[[:space:]]*>', "@CRLF", $block['EMAIL_MESSAGE_HTML']); $text = str_replace('</p>', '</p>@CRLF', $text); $text = htmlspecialchars(stripslashes(strip_tags($text))); } else { $text = strip_tags($email_text); } if (EMAIL_USE_HTML == 'true' && trim($email_html) != '' && ($customers_email_format == 'HTML' || ADMIN_EXTRA_EMAIL_FORMAT != 'TEXT' && substr($module, -6) == '_extra')) { $message->add_html($email_html, $text); } else { $message->add_text($text); $email_html = ''; // since sending a text-only message, empty the HTML portion so it's not archived either. } // process attachments if (EMAIL_ATTACHMENTS_ENABLED && zen_not_null($attachments_list)) { // while ( list($key, $value) = each($attachments_list)) { $fileraw = $message->get_file(DIR_FS_ADMIN . 'attachments/' . $attachments_list['file']); $filemime = zen_not_null($attachments_list['file_type']) ? $attachments_list['file_type'] : $message->findMime($attachments_list); //findMime determines what type this attachment is (XLS, PDF, etc) and sends proper vendor c_type. $message->add_attachment($fileraw, $attachments_list['file'], $filemime); // } //endwhile attach_list } //endif attachments // Prepare message $message->build_message(); // send the actual email $result = $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject); if (!$result) { $messageStack->add(sprintf(EMAIL_SEND_FAILED, $to_name, $to_email_address, $email_subject), 'error'); } // Archive this message to storage log if (EMAIL_ARCHIVE == 'true' && $module != 'password_forgotten_admin' && $module != 'cc_middle_digs') { // don't archive pwd-resets and CC numbers zen_mail_archive_write($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject, $email_html, $text, $module); } // endif archiving } // end foreach loop thru possible multiple email addresses }
} } $email_from = $g_db->prepare_input($_POST['email_from']); $subject = $g_db->prepare_input($_POST['subject']); $message = $g_db->prepare_input($_POST['message']); //Let's build a message object using the email class $mimemessage = new email(array('X-Mailer: Asymmetrics Mailer')); if (EMAIL_USE_HTML == 'true') { $text = strip_tags($message); $mimemessage->add_html($message, $text); } else { $mimemessage->add_text($message); } if (isset($attach_array) && is_array($attach_array)) { foreach ($attach_array as $value) { $mimemessage->add_attachment($value['attachment'], $value['name'], $value['type']); } } $mimemessage->build_message(); foreach ($mail_array as $mail) { if (tep_not_null($mail['customers_firstname']) && tep_not_null($mail['customers_lastname'])) { $name = $mail['customers_firstname'] . ' ' . $mail['customers_lastname']; } else { $name = $mail['customers_email_address']; } $mimemessage->send($name, $mail['customers_email_address'], '', $email_from, $subject); } $messageStack->add_session(sprintf(NOTICE_EMAIL_SENT_TO, $mail_sent_to), 'success'); tep_redirect(tep_href_link(basename($PHP_SELF))); break; case 'preview':