function EmailSuppliers() { $EmailText = _('This email has been automatically generated by KwaMoja') . "\n"; $EmailText .= _('You are invited to Tender for the following products to be delivered to') . ' ' . $_SESSION['CompanyRecord']['coyname'] . "\n"; $EmailText .= _('Tender number') . ': ' . $this->TenderId . "\n"; $EmailText .= _(' Quantity ') . ' ' . _(' Unit ') . ' ' . _(' Item Description') . "\n"; foreach ($this->LineItems as $LineItem) { $EmailText .= $LineItem->Quantity . ' ' . $LineItem->Units . ' ' . $LineItem->ItemDescription . "\n"; } $Subject = _('Tender received from') . ' ' . $_SESSION['CompanyRecord']['coyname']; $Headers = 'From: ' . $_SESSION['PurchasingManagerEmail'] . "\r\n" . 'Reply-To: ' . $_SESSION['PurchasingManagerEmail'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if ($_SESSION['SmtpSetting'] == 1) { include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $mail->setText($EmailText); $mail->setSubject($Subject); $mail->setFrom($_SESSION['PurchasingManagerEmail']); $mail->setHeader('Reply-To', $_SESSION['PurchasingManagerEmail']); $mail->setCc($_SESSION['PurchasingManagerEmail']); //Set this as a copy for filing purpose } foreach ($this->Suppliers as $Supplier) { $result = mail($Supplier->EmailAddress, $Subject, $EmailText, $Headers); if ($_SESSION['SmtpSetting'] == 0) { $result = mail($Supplier->EmailAddress, $Subject, $EmailText, $Headers); } else { $result = SendmailBySmtp($mail, array($Supplier->EmailAddress, $_SESSION['PurchasingManagerEmail'])); } } }
function sendMail($from, $to, $subject, $body) { $mail = new htmlMimeMail(); $mail->setFrom($from); $mail->setSubject($subject); $mail->setText($body); if (is_array($to)) { $result = $mail->send($to); } else { $result = $mail->send(array($to)); } return $result; }
} $LeftOvers = $pdf->addTextWrap($FormDesign->Comments->x, $YPos, $FormDesign->Comments->Length, $FormDesign->Comments->FontSize, $LeftOvers, 'left'); } $Success = 1; //assume the best and email goes - has to be set to 1 to allow update status if ($MakePDFThenDisplayIt) { $pdf->OutputD($_SESSION['DatabaseName'] . '_WorkOrder_' . $SelectedWO . '_' . date('Y-m-d') . '.pdf'); $pdf->__destruct(); } else { $PdfFileName = $_SESSION['DatabaseName'] . '_WorkOrder_' . $SelectedWO . '_' . date('Y-m-d') . '.pdf'; $pdf->Output($_SESSION['reports_dir'] . '/' . $PdfFileName, 'F'); $pdf->__destruct(); include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $PdfFileName); $mail->setText(_('Please Process this Work order number') . ' ' . $SelectedWO); $mail->setSubject(_('Work Order Number') . ' ' . $SelectedWO); $mail->addAttachment($attachment, $PdfFileName, 'application/pdf'); //since sometime the mail server required to verify the users, so must set this information. if ($_SESSION['SmtpSetting'] == 0) { //use the mail service provice by the server. $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $Success = $mail->send(array($_POST['EmailTo'])); } else { if ($_SESSION['SmtpSetting'] == 1) { $Success = SendmailBySmtp($mail, array($_POST['EmailTo'])); } else { prnMsg(_('The SMTP settings are wrong, please ask administrator for help'), 'error'); exit; include 'includes/footer.inc'; }
function SendMail($from, $to, $subj, $body, $attach = "") { $mail = new htmlMimeMail(); $mail->setFrom($from); $mail->setSubject($subj); $mail->setText($body); $mail->setTextCharset('windows-1251'); if ($attach != '') { $attach_data = $mail->getFile($attach); $mail->addAttachment($attach_data, basename($attach), ''); } $result = $mail->send(array($to)); return $result; }
$YPos -= 2 * $line_height; } $YPos -= 2 * $line_height; /*Print out the grand totals */ $LeftOvers = $pdf->addTextWrap(80, $YPos, 260 - $Left_Margin, $FontSize, _('Grand Total Value'), 'right'); $DisplayTotalVal = locale_money_format($Tot_Val, $_SESSION['CompanyRecord']['currencydefault']); $LeftOvers = $pdf->addTextWrap(500, $YPos, 60, $FontSize, $DisplayTotalVal, 'right'); if ($_POST['DetailedReport'] == 'Yes') { $pdf->line($Left_Margin, $YPos + $line_height - 2, $Page_Width - $Right_Margin, $YPos + $line_height - 2); $YPos -= 2 * $line_height; } if ($ListCount == 0) { $title = _('Print Inventory Valuation Error'); include 'includes/header.inc'; echo '<br />' . _('There were no items with any value to print out for the location specified'); echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; include 'includes/footer.inc'; exit; // Javier: needs check } else { include 'includes/htmlMimeMail.php'; $pdf->Output($_SESSION['reports_dir'] . '/InventoryReport.pdf', 'F'); $pdf->__destruct(); $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/InventoryReport.pdf'); $mail->setText(_('Please find herewith the stock valuation report')); $mail->setSubject(_('Inventory Valuation Report')); $mail->addAttachment($attachment, 'InventoryReport.pdf', 'application/pdf'); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] . ">"); $result = $mail->send($Recipients); }
} if ($_SESSION['SalesmanLogin'] != '') { $sql .= " AND debtortrans.salesperson='" . $_SESSION['SalesmanLogin'] . "'"; } $ErrMsg = _('Could not retrieve the count of sales order lines in the period under review'); $result = DB_query($sql, $db, $ErrMsg); $myrow = DB_fetch_row($result); $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, _('Total number of order lines') . ' ' . locale_number_format($myrow[0]), 'left'); $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, _('DIFOT') . ' ' . locale_number_format((1 - $TotalDiffs / $myrow[0]) * 100, 2) . '%', 'left'); $ReportFileName = $_SESSION['DatabaseName'] . '_DeliveryDifferences_' . date('Y-m-d') . '.pdf'; $pdf->OutputD($ReportFileName); if ($_POST['Email'] == 'Yes') { if (file_exists($_SESSION['reports_dir'] . '/' . $ReportFileName)) { unlink($_SESSION['reports_dir'] . '/' . $ReportFileName); } $pdf->Output($_SESSION['reports_dir'] . '/' . $ReportFileName, 'F'); include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $ReportFileName); $mail->setText(_('Please find herewith delivery differences report from') . ' ' . $_POST['FromDate'] . ' ' . _('to') . ' ' . $_POST['ToDate']); $mail->addAttachment($attachment, $ReportFileName, 'application/pdf'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send(array($_SESSION['FactoryManagerEmail'])); } else { $result = SendmailBySmtp($mail, array($_SESSION['FactoryManagerEmail'])); } } $pdf->__destruct();
} } if (sizeOf($RejectsArray) > 0) { $MailText = _('This email has been automatically generated by the webERP installation at') . ' ' . $_SESSION['CompanyRecord']['coyname'] . "\n"; $MailText .= _('The following offers you made have been rejected') . "\n\n"; foreach ($RejectsArray as $RejectID) { $sql = "SELECT offers.quantity,\n\t\t\t\t\t\t\toffers.price,\n\t\t\t\t\t\t\tstockmaster.description\n\t\t\t\t\t\tFROM offers\n\t\t\t\t\t\tLEFT JOIN stockmaster\n\t\t\t\t\t\t\tON offers.stockid=stockmaster.stockid\n\t\t\t\t\t\tWHERE offerid='" . $RejectID . "'"; $result = DB_query($sql); $myrow = DB_fetch_array($result); $MailText .= $myrow['description'] . "\t" . _('Quantity') . ' ' . $myrow['quantity'] . "\t" . _('Price') . ' ' . locale_number_format($myrow['price']) . "\n"; $sql = "DELETE FROM offers WHERE offerid='" . $RejectID . "'"; $result = DB_query($sql); } $mail = new htmlMimeMail(); $mail->setSubject(_('Your offer to') . ' ' . $_SESSION['CompanyRecord']['coyname'] . ' ' . _('has been rejected')); $mail->setText($MailText); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $Recipients = GetMailList('OffersReceivedResultRecipients'); if (sizeOf($Recipients) == 0) { prnMsg(_('There are no members of the Offers Received Result Recipients email group'), 'warn'); include 'includes/footer.inc'; exit; } array_push($Recipients, $Email); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } if ($result) {
$TaxGroupTaxesResult = DB_query("SELECT taxgroupid,\n\t\t\t\t\t taxauthid,\n\t\t\t\t\t calculationorder,\n\t\t\t\t\t taxontax\n\t\t\t\t\t FROM taxgrouptaxes"); while ($TaxGroupTaxesRow = DB_fetch_array($TaxGroupTaxesResult)) { $SQLScript .= "INSERT INTO taxgrouptaxes (taxgroupid,\n taxauthid,\n calculationorder,\n taxontax)\n VALUES (" . $TaxGroupTaxesRow['taxgroupid'] . ",\n " . $TaxGroupTaxesRow['taxauthid'] . ",\n " . $TaxGroupTaxesRow['calculationorder'] . ",\n " . $TaxGroupTaxesRow['taxontax'] . ");\n"; } $SQLScript .= "SET FOREIGN_KEY_CHECKS=1;"; /*Now write $SQLScript to a file */ $FileHandle = fopen("./companies/" . $_SESSION['DatabaseName'] . "/reports/" . $_POST['TemplateName'] . ".sql", "w"); fwrite($FileHandle, $SQLScript); fclose($FileHandle); echo '<P><a href="' . $RootPath . '/companies/' . $_SESSION['DatabaseName'] . '/reports/' . $_POST['TemplateName'] . '.sql">' . _('Show the sql template file produced') . '</a>'; include 'includes/htmlMimeMail.php'; $Recipients = array('"Submissions" <*****@*****.**>'); $mail = new htmlMimeMail(); $Host = $_SERVER['HTTP_HOST']; $attachment = $mail->getFile('http://' . $Host . $RootPath . '/companies/' . $_SESSION['DatabaseName'] . '/reports/' . $_POST['TemplateName'] . '.sql'); $mail->setText('Please find company template ' . $_POST['TemplateName']); $mail->addAttachment($attachment, 'CompanyTemplate.sql', 'application/txt'); $mail->setSubject('Company Template Submission'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } /*end of SQL Script creation */ } /*end if Input error*/ } /*end submit button hit */ echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">'; echo '<div class="centre">';
function welcome_email_send(&$registration_details) { global $main_smarty, $current_user; include_once mnminclude . 'user.php'; // Check User ID != 0 if ($registration_details['id'] > 0) { $username = $registration_details['username']; $password = $registration_details['password']; $email = $registration_details['email']; $id = $registration_details['id']; $user = new User(); $user->id = $id; // Check User Data if ($user->read()) { include_once mnmmodules . 'welcome_email/includes/htmlMimeMail.php'; // Current Date/Time of Server $thisDate = date("M d, Y"); $thisTime = date("H:i:s"); // User Information $thisUserName = $username; $thisUserEmail = $email; // Pligg Information $siteName = $main_smarty->get_config_vars('PLIGG_Visual_Name'); $siteEmail = $main_smarty->get_config_vars('PLIGG_PassEmail_From'); $installedURL = my_base_url; $installedBase = my_pligg_base; // Email Subject $messageSubject = "Welcome to " . $siteName . "!"; // Email Message $messageText = "Hello, " . $thisUserName . ".\n\n"; $messageText .= "Your account at " . $siteName . " has been successfully set up.\n\n"; $messageText .= "Please keep the below information for future reference:\n"; $messageText .= "-----------------------------------------\n\n"; $messageText .= " Login URL: " . $installedURL . $installedBase . "/login.php\n\n"; $messageText .= " Username.: " . $thisUserName . "\n"; $messageText .= " Password.: (password choosen when registered)\n\n"; $messageText .= "-----------------------------------------\n"; $messageText .= "Email has been automatically generated on " . $thisDate . " at " . $thisTime . ".\n"; // Setup Mail Class $mail = new htmlMimeMail(); // Set Mail Body Text $mail->setText($messageText); // Set Mail From $mail->setFrom($siteName . " <" . $siteEmail . ">"); // Set Mail Subject $mail->setSubject($messageSubject); // Send Mail $mail->send(array($thisUserEmail)); } else { // Unable to find user data echo "Module Error #2"; die; // To disable this error message and continue with registration, // remove the above ELSE statement this comment is within. } } else { // Unable to find User ID echo "Module Error #1"; die; } }
/** * Replace placeholders in mail templates and send * e-mails. */ function send_mail($mail_content, $content_data, $post_data = null) { global $text_wrap, $my_sendmail, $send_alternative_mail, $debug_mode, $sender_count, $sender_duration, $recipient_count, $recipient_duration, $txt, $remove_tags, $tplt, $configuration; $multiple = $this->collect_multiples($post_data); $mail_content = $this->replace_multiples($mail_content, $multiple); for ($i = 0; $i < count($mail_content); $i++) { /** * Replace placeholder with form, text (from language * file) and environment data */ $mail_content[$i] = $this->replace_values($mail_content[$i], $post_data); $mail_content[$i] = $this->replace_values($mail_content[$i], $txt); $mail_content[$i] = $this->replace_values($mail_content[$i], $content_data); $mail_content[$i] = $this->replace_values($mail_content[$i], $this->get_environment_var($_SERVER)); //$mail_content[$i] = $this->replace_values($mail_content[$i], $url); /** * Remove unselected value placeholders */ $mail_content[$i] = $this->remove_values($mail_content[$i]); /** * Remove tags */ // $mail_content[$i] = $this->clean_output($mail_content[$i], $remove_tags); /** * Strip slashes */ $final_mail_content = stripslashes($mail_content[$i]); if ($this->validate_to($final_mail_content) == false) { continue; } /** * Check whether the user is allowed to send e-mails * with or to a certain e-mail address. */ $sender = $this->get_header_info($mail_content[$i], 'From'); $recipient = $this->get_header_info($mail_content[$i], 'To'); // Check if recipient is blocked by domain if (sizeof($configuration['recipients_domains']) > 0) { foreach ($configuration['recipients_domains'] as $recipient_domain) { $domain = '#' . preg_quote(trim($recipient_domain)) . '#'; if (preg_match($domain, $recipient) === 1) { return array('status' => 'failed', 'message' => array(), 'mail_content' => $mail_content[$i]); } } } if ($tplt == 'recom') { if ($limit = $this->check_value_limit($sender, $sender_count, $sender_duration, 4, $txt['txt_sender_expiration'])) { $message[] = array('message' => $limit, 'fields' => ''); } if ($limit = $this->check_value_limit($recipient, $recipient_count, $recipient_duration, 5, $txt['txt_recipient_expiration'])) { $message[] = array('message' => $limit, 'fields' => ''); } if (isset($message) and !empty($message)) { return array('status' => 'failed', 'message' => $message); } } /** * Start attachment handling */ $send_attachments = false; if (!empty($this->attachments) and is_array($this->attachments)) { $send_alternative_mail = 'yes'; $send_attachments = true; } if (isset($configuration['attach_mail_vars']) and is_array($configuration['attach_mail_vars']) and sizeof($configuration['attach_mail_vars']) > 0) { $send_alternative_mail = 'yes'; $send_attachments = true; } /** * Get sendmail path from php ini settings or use the * value of $my_sendmail. */ if ($send_alternative_mail != 'yes') { $sendmail = @ini_get('sendmail_path'); debug_mode($sendmail, 'ini_get()'); if (empty($sendmail)) { $sendmail = "/usr/sbin/sendmail -t "; debug_mode($sendmail, 'empty($sendmail)'); } if (isset($my_sendmail) and !empty($my_sendmail)) { $sendmail = $my_sendmail; debug_mode(array('$my_sendmail', $sendmail)); } /** * Try to send e-mail by using popen() to access * sendmail. */ if ($fd = @popen($sendmail, "w")) { if (!@fputs($fd, $final_mail_content . "\n")) { $send_alternative_mail = 'yes'; debug_mode(array($txt['txt_popen_error'] . ' - fputs()', gettype($fd), $fd)); } pclose($fd); } else { $send_alternative_mail = 'yes'; debug_mode(array($txt['txt_popen_error'] . ' - popen()', gettype($fd), $fd)); } debug_mode($final_mail_content, 'Mail Content popen()'); } /** * If popen() - or fputs() - fails, extract mail * header from the template and use the PHP function * mail(). */ if ($send_alternative_mail == 'yes') { $header_info = explode("\n", $final_mail_content); $mail_subject = ''; $mail_header = $this->mail_headers; $mail_header = join($mail_header, '|'); unset($additional_headers); $attachment_headers = array(); for ($k = 0; $k < count($header_info); $k++) { $clean_header = trim($header_info[$k]); if (empty($clean_header)) { break; } if (preg_match("/^From:/i", $header_info[$k])) { $mail_from = trim(preg_replace("/From:/i", '', $header_info[$k])); $attachment_headers['From'] = $mail_from; unset($header_info[$k]); continue; } if (preg_match("/^To:/i", $header_info[$k])) { $mail_recipient = trim(preg_replace("/^To:/i", '', $header_info[$k])); unset($header_info[$k]); continue; } if (preg_match("/^Subject:/i", $header_info[$k])) { $mail_subject = trim(preg_replace("/^Subject:/i", '', $header_info[$k])); unset($header_info[$k]); continue; } if (preg_match("/^X-Form-Mail-Attachment:/i", $header_info[$k])) { if (trim(str_replace('X-Form-Mail-Attachment:', '', $header_info[$k])) == 'no') { $send_attachments = false; } unset($header_info[$k]); continue; } if (preg_match("/^" . $mail_header . "/i", $header_info[$k], $match)) { $additional_headers[] = $header_info[$k]; $attachment_headers[str_replace(':', '', $match[0])] = trim(preg_replace("/" . $match[0] . "/i", '', $header_info[$k])); unset($header_info[$k]); continue; } } if (isset($header_info) and is_array($header_info)) { $new_mail_content = trim(implode($header_info, "\n")); $new_mail_content = str_replace("\r", '', $new_mail_content); } else { $new_mail_content = ''; } // if (isset($additional_headers) and is_array($additional_headers)) { // $additional_headers = implode($additional_headers, "\n"); // } else { // $additional_headers = ''; // } /** * Wrap mail content (and only mail content - not * headers). */ $new_mail_content = $this->wrap_content($new_mail_content, $text_wrap); /** * Send mail using simple mail function */ if (!$send_attachments and $debug_mode != 'on' and $mail_recipient != '') { // @mail ($mail_recipient, $mail_subject, $new_mail_content, $additional_headers); send_mail($mail_recipient, $mail_subject, $new_mail_content, $mail_from, $attachment_headers); } /** * Send mail using mail class */ if ($send_attachments and $debug_mode != 'on' and $mail_recipient != '') { $att = new htmlMimeMail(); // Switch to smtp mode if ($configuration['mail_type'] == 'smtp') { $type = 'smtp'; $smtp = $configuration['smtp']; $att->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']); } else { $type = 'mail'; } // Register file attachments in mime class foreach ($this->attachments as $file_name) { $att->addAttachment($att->getFile($file_name['new']), $file_name['old']); } //Manage mail var attachments if (isset($configuration['attach_mail_vars']) and is_array($configuration['attach_mail_vars']) and sizeof($configuration['attach_mail_vars']) > 0) { foreach ($configuration['attach_mail_vars'] as $attach_type) { if ($attach_type == 'vcard') { $attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_VCARD, 'control' => $this->control_fields); if ($res = attach_mail_variables::get_content($attach_config)) { $att->addAttachment($res, 'vcard.vcf'); } } if ($attach_type == 'csv') { $attach_config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_CSV, 'control' => $this->control_fields, 'csv_head' => true); if ($res = attach_mail_variables::get_content($attach_config)) { $att->addAttachment($res, 'csv.csv'); } } } } // Register headers in mime class $html = false; if (isset($attachment_headers) and is_array($attachment_headers)) { foreach ($attachment_headers as $key => $val) { $att->setHeader($key, $val); if ($key == 'Content-Type' and preg_match('#text/html#i', $val)) { $att->setHtmlCharset($configuration['character_set']); $att->setHtml($new_mail_content); $html = true; } } } $att->setHeadCharset($configuration['character_set']); $att->setSubject($mail_subject); if ($html != true) { $att->setTextCharset($configuration['character_set']); $att->setText($new_mail_content); } $att->send(array($mail_recipient), $type); } debug_mode($mail_recipient, 'Mail Recipient mail()'); debug_mode($mail_subject, 'Mail Subject mail()'); debug_mode($new_mail_content, 'Mail Content mail()'); debug_mode($additional_headers, 'Mail Additional Headers mail()'); } } // -re- for $this->mail_content = $mail_content[0]; return array('status' => 'ok', 'mail_content' => $this->mail_content); }
$LeftOvers = $pdf->addTextWrap($Left_Margin + $Col9, $YPos, $Col10 - $Col9 - 5, $FontSize, $myrow['salesmanname'], 'left'); if ($YPos - 2 * $line_height < $Bottom_Margin) { $PageNumber++; include 'includes/PDFWeeklyOrdersPageHeader.inc'; } /*end of new page header */ $YPos -= $line_height; } //while include 'includes/htmlMimeMail.php'; $filename = $_SESSION['reports_dir'] . '/SalesBySalesperson.pdf'; $pdf->Output($filename, 'F'); $pdf->__destruct(); $mail = new htmlMimeMail(); $attachment = $mail->getFile($filename); $mail->setText(_('Please find the Sales By Salesperson report')); $mail->setSubject(_('Sales By Salesperson Report')); $mail->addAttachment($attachment, $filename, 'application/pdf'); //echo '<br /><div class="centre"><a href="' . $RootPath . '/' . $filename . '">' . _('click here') . '</a> ' . _('to view the file') . '</div>'; if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } if ($result) { $Title = _('Print Weekly Orders'); include 'includes/header.inc'; prnMsg(_('The Weekly Orders report has been mailed'), 'success'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; include 'includes/footer.inc';
function EmailOffer() { $Subject = _('Offer received from') . ' ' . $this->GetSupplierName(); $Message = _('This email is automatically generated by webERP') . "\n" . _('You have received the following offer from') . ' ' . $this->GetSupplierName() . "\n\n" . $this->OfferMailText; $Headers = 'From: ' . $this->GetSupplierEmail() . "\r\n" . 'Reply-To: ' . $this->GetSupplierEmail() . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if ($_SESSION['SmtpSetting'] == 1) { include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $mail->setText($Message); $mail->setSubject($Subject); $mail->setFrom($this->GetSupplierEmail()); $mail->setHeader('Reply-To', $this->GetSupplierEmail()); $mail->setCc($this->GetSupplierEmail()); } if ($_SESSION['SmtpSetting'] == 0) { $result = mail($_SESSION['PurchasingManagerEmail'], $Subject, $Message, $Headers); } else { $result = SendmailBySmtp($mail, array($Supplier->EmailAddress, $_SESSION['PurchasingManagerEmail'])); } return $result; }
$Recipient[$i] = "<" . $Recipient[$i] . ">"; } $AllowAnyone = true; include 'includes/session.inc'; include 'includes/ConstructSQLForUserDefinedSalesReport.inc'; include 'includes/PDFSalesAnalysis.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); if ($Counter > 0) { /* the number of lines of the sales report is more than 0 ie there is a report to send! */ $pdfcode = $pdf->output(); $fp = fopen($_SESSION['reports_dir'] . "/" . $reportname, "wb"); fwrite($fp, $pdfcode); fclose($fp); $attachment = $mail->getFile($_SESSION['reports_dir'] . "/" . $reportname); $mail->setText($mailtext . "\nPlease find herewith " . $reportname . " report"); $mail->setSubject($reportname . " Report"); $mail->addAttachment($attachment, $reportname, 'application/pdf'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom(""); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } } else { $mail->setText("Error running automated sales report number {$ReportID}"); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom("Do_not_reply_" . $_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] . ">"); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients);
$sql = "SELECT COUNT(salesorderdetails.orderno)\n\t\tFROM salesorderdetails INNER JOIN debtortrans\n\t\t\tON salesorderdetails.orderno=debtortrans.order_ INNER JOIN stockmaster\n\t\t\tON salesorderdetails.stkcode=stockmaster.stockid INNER JOIN salesorders\n\t\t\tON salesorderdetails.orderno = salesorders.orderno INNER JOIN locationusers\n\t\t\tON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1\n\t\tWHERE debtortrans.trandate>='" . FormatDateForSQL($_POST['FromDate']) . "'\n\t\tAND debtortrans.trandate <='" . FormatDateForSQL($_POST['ToDate']) . "'\n\t\tAND stockmaster.categoryid='" . $_POST['CategoryID'] . "'"; } elseif ($_POST['CategoryID'] == 'All' and $_POST['Location'] != 'All') { $sql = "SELECT COUNT(salesorderdetails.orderno)\n\t\tFROM salesorderdetails INNER JOIN debtortrans\n\t\t\tON salesorderdetails.orderno=debtortrans.order_ INNER JOIN salesorders\n\t\t\tON salesorderdetails.orderno = salesorders.orderno INNER JOIN locationusers\n\t\t\tON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1\n\t\tWHERE debtortrans.trandate>='" . FormatDateForSQL($_POST['FromDate']) . "'\n\t\tAND debtortrans.trandate <='" . FormatDateForSQL($_POST['ToDate']) . "'\n\t\tAND salesorders.fromstkloc='" . $_POST['Location'] . "'"; } elseif ($_POST['CategoryID'] != 'All' and $_POST['Location'] != 'All') { $sql = "SELECT COUNT(salesorderdetails.orderno)\n\t\tFROM salesorderdetails INNER JOIN debtortrans ON salesorderdetails.orderno=debtortrans.order_\n\t\t\tINNER JOIN salesorders ON salesorderdetails.orderno = salesorders.orderno\n\t\t\tINNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1\n\t\t\tINNER JOIN stockmaster ON salesorderdetails.stkcode = stockmaster.stockid\n\t\tWHERE salesorders.fromstkloc ='" . $_POST['Location'] . "'\n\t\tAND categoryid='" . $_POST['CategoryID'] . "'\n\t\tAND trandate >='" . FormatDateForSQL($_POST['FromDate']) . "'\n\t\tAND trandate <= '" . FormatDateForSQL($_POST['ToDate']) . "'"; } $ErrMsg = _('Could not retrieve the count of sales order lines in the period under review'); $result = DB_query($sql, $ErrMsg); $myrow = DB_fetch_row($result); $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, _('Total number of order lines') . ' ' . locale_number_format($myrow[0]), 'left'); $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, _('DIFOT') . ' ' . locale_number_format((1 - $TotalDiffs / $myrow[0]) * 100, 2) . '%', 'left'); $ReportFileName = $_SESSION['DatabaseName'] . '_DIFOT_' . date('Y-m-d') . '.pdf'; $pdf->OutputD($ReportFileName); if ($_POST['Email'] == 'Yes') { $pdf->Output($_SESSION['reports_dir'] . '/' . $ReportFileName, 'F'); include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $ReportFileName); $mail->setText(_('Please find herewith DIFOT report from') . ' ' . $_POST['FromDate'] . ' ' . _('to') . ' ' . $_POST['ToDate']); $mail->addAttachment($attachment, 'DIFOT.pdf', 'application/pdf'); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send(array($_SESSION['FactoryManagerEmail'])); } else { $result = SendmailBySmtp($mail, array($_SESSION['FactoryManagerEmail'])); } } $pdf->__destruct();
check_ticket('webmail'); $a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach2file"]); $mail->addAttachment($a2, $_REQUEST["attach2"], $_REQUEST["attach2type"]); @unlink('temp/mail_attachs/' . $_REQUEST["attach2file"]); } if ($_REQUEST["attach3"]) { check_ticket('webmail'); $a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach3file"]); $mail->addAttachment($a3, $_REQUEST["attach3"], $_REQUEST["attach3type"]); @unlink('temp/mail_attachs/' . $_REQUEST["attach3file"]); } $mail->setSMTPParams($current["smtp"], $current["smtpPort"], '', $current["useAuth"], $current["username"], $current["pass"]); if (isset($_REQUEST["useHTML"]) && $_REQUEST["useHTML"] == 'on') { $mail->setHTML($_REQUEST["body"], strip_tags($_REQUEST["body"])); } else { $mail->setText($_REQUEST["body"]); } $to_array_1 = split('[, ;]', $_REQUEST["to"]); $to_array = array(); foreach ($to_array_1 as $to_1) { if (!empty($to_1)) { $to_array[] = $to_1; } } $to_array = $webmaillib->parse_nicknames($to_array); // Get email addresses not in the address book $not_contacts = $webmaillib->are_contacts($to_array, $user); if (count($not_contacts) > 0) { $smarty->assign('notcon', 'y'); } else { $smarty->assign('notcon', 'n');
/** * Send e-mails * * @param String $to Recipient mail address * @param String $subject Subject * @param String $message Mail content * @param String $from Sender mail address * @param Array $headers Additional mail headers * * @return Bool Returs true if mail has been sent */ function send_mail($to, $subject, $message, $from, $headers = NULL) { global $configuration; $mail = new htmlMimeMail(); if ($configuration['mail_type'] == 'smtp') { $type = 'smtp'; $smtp = $configuration['smtp']; $mail->setSMTPParams($smtp['host'], $smtp['port'], $smtp['helo'], $smtp['auth'], $smtp['user'], $smtp['pass']); } else { $type = 'mail'; } // Set additional mail headers $html = false; if (is_array($headers)) { foreach ($headers as $name => $value) { $mail->setHeader($name, $value); if (strtolower($name) == 'content-type' and preg_match('#text/html#i', $value)) { $mail->setHtmlCharset($configuration['character_set']); $mail->setHtml($message); $html = true; } // Set return path if (strtolower($name) == 'return-path') { $mail->setReturnPath($value); } } } $mail->setHeadCharset($configuration['character_set']); $mail->setFrom($from); $mail->setSubject($subject); if ($html != true) { $configuration['character_set']; $mail->setTextCharset($configuration['character_set']); $mail->setText($message); } $result = $mail->send(array($to), $type); if ($result) { return true; } }
/*Then set up a new page */ $PageNumber++; include 'includes/PDFChequeListingPageHeader.inc'; } /*end of new page header */ } /* end of while there are customer receipts in the batch to print */ $YPos -= $line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 60, $FontSize, locale_money_format($TotalCheques, $Currency), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin + 65, $YPos, 300, $FontSize, _('TOTAL') . ' ' . $Currency . ' ' . _('CHEQUES'), 'left'); $ReportFileName = $_SESSION['DatabaseName'] . '_ChequeListing_' . date('Y-m-d') . '.pdf'; $pdf->OutputD($ReportFileName); //UldisN $pdf->__destruct(); //UldisN if ($_POST['Email'] == 'Yes') { if (file_exists($_SESSION['reports_dir'] . '/' . $ReportFileName)) { unlink($_SESSION['reports_dir'] . '/' . $ReportFileName); } $fp = fopen($_SESSION['reports_dir'] . '/' . $ReportFileName, 'wb'); fwrite($fp, $pdfcode); fclose($fp); include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $ReportFileName); $mail->setText(_('Please find herewith payments listing from') . ' ' . $_POST['FromDate'] . ' ' . _('to') . ' ' . $_POST['ToDate']); $mail->addAttachment($attachment, 'PaymentListing.pdf', 'application/pdf'); $mail->setFrom(array('"' . $_SESSION['CompanyRecord']['coyname'] . '" <' . $_SESSION['CompanyRecord']['email'] . '>')); /* $ChkListingRecipients defined in config.php */ $result = $mail->send($ChkListingRecipients); }
$TotalGP = ($TotalSalesValue - $TotalSalesCost) / $TotalSalesValue * 100; } else { $TotalGP = 0; } $LeftOvers = $pdf->addTextWrap($Left_Margin + $Col2, $YPos, $Col3 - $Col2 - 5, $FontSize, _('Monthly Invoiced Total'), 'left'); $LeftOvers = $pdf->addTextWrap($Left_Margin + $Col6, $YPos, $Col7 - $Col6 - 5, $FontSize, locale_number_format($TotalSalesVolume, $_SESSION['CompanyRecord']['decimalplaces']), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin + $Col7, $YPos, $Col8 - $Col7 - 5, $FontSize, locale_number_format($TotalSalesValue, $_SESSION['CompanyRecord']['decimalplaces']), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin + $Col8, $YPos, $Col9 - $Col8 - 5, $FontSize, locale_number_format($TotalSalesCost, $_SESSION['CompanyRecord']['decimalplaces']), 'right'); $LeftOvers = $pdf->addTextWrap($Left_Margin + $Col9, $YPos, $Col10 - $Col9 - 5, $FontSize, locale_number_format($TotalGP, 2), 'right'); include 'includes/htmlMimeMail.php'; $filename = $_SESSION['reports_dir'] . '/WeeklyOrders.pdf'; $pdf->Output($filename, 'F'); $pdf->__destruct(); $mail = new htmlMimeMail(); $attachment = $mail->getFile($filename); $mail->setText(_('Please find the weekly order report')); $mail->setSubject(_('Weekly Orders Report')); $mail->addAttachment($attachment, $filename, 'application/pdf'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } if ($result) { $Title = _('Print Weekly Orders'); include 'includes/header.inc'; prnMsg(_('The Weekly Orders report has been mailed'), 'success'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; include 'includes/footer.inc'; exit;
chdir($kwamoja_home); // get me the report name from the command line $_GET['ReportID'] = $reportnumber; $Recipients = explode(";", $emailaddresses); //wrap in angles so that mail can accept it for ($i = 0; $i < count($Recipients); $i++) { $Recipient[$i] = "<" . $Recipient[$i] . ">"; } $AllowAnyone = true; include 'includes/session.inc'; include 'includes/ConstructSQLForUserDefinedSalesReport.inc'; include 'includes/PDFSalesAnalysis.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); if ($Counter > 0) { /* the number of lines of the sales report is more than 0 ie there is a report to send! */ $pdfcode = $pdf->output(); $fp = fopen($_SESSION['reports_dir'] . "/" . $reportname, "wb"); fwrite($fp, $pdfcode); fclose($fp); $attachment = $mail->getFile($_SESSION['reports_dir'] . "/" . $reportname); $mail->setText($mailtext . "\nPlease find herewith " . $reportname . " report"); $mail->setSubject($reportname . " Report"); $mail->addAttachment($attachment, $reportname, 'application/pdf'); $mail->setFrom(""); $result = $mail->send($Recipients); } else { $mail->setText("Error running automated sales report number {$ReportID}"); $mail->setFrom("Do_not_reply_" . $_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] . ">"); $result = $mail->send($Recipients); }
/** * Find the specified error message, and return the first found with the following precedence: * 1. Current language(s) set by setMsgLangage() * 2. English message * 3. Debug message * 4. Generic error * Each language can be found through ['lnk'] if needed * Tags (%1..%n) in the message are replaced by mixed arguments specified after $errNum. * Ex: errorMsg(55, $domainName) * if 'dbg' is found in ['add'] or $DisplayDbg is true, the 'dbg' version is appended to the found version. */ function errorMsg($errNum = GENERIC_ERROR_NUM) { // Find specified message using precedence rules global $MsgLanguages; $precedence = array(array($errNum, $MsgLanguages == 'all' ? array('en', 'fr', 'de') : $MsgLanguages), array($errNum, array('en')), array($errNum, array('dbg')), array(GENERIC_ERROR_NUM, $MsgLanguages), array(GENERIC_ERROR_NUM, array('en'))); global $ErrMsgs; $args = func_get_args(); $msg = ''; foreach ($precedence as $rule) { // Find message list($actualErrNum, $languages) = $rule; foreach ($languages as $lg) { if (isset($ErrMsgs[$actualErrNum][$lg]) && $ErrMsgs[$actualErrNum][$lg] != 'TODO') { appendToMsg($msg, $errNum, $ErrMsgs[$actualErrNum][$lg], $args); } else { if (isset($ErrMsgs[$actualErrNum]['lnk']) && isset($ErrMsgs[$actualErrNum]['lnk'][$lg]) && $ErrMsgs[$actualErrNum]['lnk'][$lg] != 'TODO') { appendToMsg($msg, $errNum, $ErrMsgs[$actualErrNum]['lnk'][$lg], $args); } } } // Try next rule only if not found if (!empty($msg)) { break; } } // Add debug version if needed global $DisplayDbg; $msgHasDebug = in_array('dbg', $languages); $logExtMsg = ''; if (!$msgHasDebug && isset($ErrMsgs[$actualErrNum]['dbg'])) { if ($DisplayDbg || isset($ErrMsgs[$actualErrNum]['add']) && $ErrMsgs[$actualErrNum]['add'] == 'dbg') { $msg .= '[' . $ErrMsgs[$actualErrNum]['dbg'] . "]\n"; } else { $logExtMsg .= '[' . $ErrMsgs[$actualErrNum]['dbg'] . ']'; } // to log message } // Get mail data if specified $mailData = isset($ErrMsgs[$actualErrNum]['mail']) ? $ErrMsgs[$actualErrNum]['mail'] : (isset($ErrMsgs[$actualErrNum]['lnk']['mail']) ? $ErrMsgs[$actualErrNum]['lnk']['mail'] : array()); // Apply params if applicable $numArgs = func_num_args(); if ($numArgs > 1) { for ($i = 0; $i != $numArgs; ++$i) { $msg = str_replace("%{$i}", $args[$i], $msg); $logExtMsg = str_replace("%{$i}", $args[$i], $logExtMsg); $mIdx = 0; foreach ($mailData as $field) { $mailData[$mIdx] = str_replace("%{$i}", $args[$i], $field); ++$mIdx; } } } // Log technical errors if possible $logMode = isset($ErrMsgs[$actualErrNum]['log']) ? $ErrMsgs[$actualErrNum]['log'] : (isset($ErrMsgs[$actualErrNum]['lnk']['log']) ? $ErrMsgs[$actualErrNum]['lnk']['log'] : true); if ($logMode && class_exists('CWwwLog')) { $logFile = new CWwwLog(); $logFile->logStr($logExtMsg); // message is already logged by ob_callback_r2login() } // Send email if specified if (!empty($mailData) && count($mailData) >= 3) { include_once 'email/htmlMimeMail.php'; $mail = new htmlMimeMail(); $mail->setFrom('*****@*****.**'); $mail->setSubject($mailData[1]); $mail->setText('Application: ' . $_GET['clientApplication'] . ' - Login: '******'login'] . "\n" . $mailData[2]); $result = $mail->send(array($mailData[0])); } return $msg; }
and an array of the receipients */ /*The following three variables need to be modified for the report - the company database to use and the receipients */ /*The Sales report to send */ $_GET['ReportID'] = 2; /*The company database to use */ $DatabaseName = 'kwamojademo'; /*The people to receive the emailed report */ $Recipients = array('"Root" <root@localhost>', '"' . _('someone else') . '" <*****@*****.**>'); $AllowAnyone = true; include 'includes/session.inc'; include 'includes/ConstructSQLForUserDefinedSalesReport.inc'; include 'includes/PDFSalesAnalysis.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); if ($Counter > 0) { /* the number of lines of the sales report is more than 0 ie there is a report to send! */ $pdfcode = $pdf->output(); $fp = fopen($_SESSION['reports_dir'] . '/SalesReport.pdf', 'wb'); fwrite($fp, $pdfcode); fclose($fp); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/SalesReport.pdf'); $mail->setText(_('Please find herewith sales report')); $mail->SetSubject(_('Sales Analysis Report')); $mail->addAttachment($attachment, 'SalesReport.pdf', 'application/pdf'); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $mail->setText(_('Error running automated sales report number') . ' ' . $ReportID); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); }
* * Create the mail object. */ $mail = new htmlMimeMail(); /** * Read the file test.zip into $attachment. */ $attachment = $mail->getFile('example.zip'); /** * Since we're sending a plain text email, * we only need to read in the text file. */ $text = $mail->getFile('example.txt'); /** * To set the text body of the email, we * are using the setText() function. This * is an alternative to the setHtml() function * which would obviously be inappropriate here. */ $mail->setText($text); /** * This is used to add an attachment to * the email. */ $mail->addAttachment($attachment, 'example.zip', 'application/zip'); /** * Sends the message. */ $mail->setFrom('Joe <*****@*****.**>'); $result = $mail->send(array('"Richard" <postmaster@localhost>')); echo $result ? 'Mail sent!' : 'Failed to send mail';
/*end if there are order details to show on the order*/ //} /* end of check to see that there was an order selected to print */ $Success = 1; //assume the best and email goes - has to be set to 1 to allow update status if ($MakePDFThenDisplayIt) { $pdf->OutputD($_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf'); $pdf->__destruct(); } else { /* must be MakingPDF to email it */ $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . $OrderNo . '_' . date('Y-m-d') . '.pdf'; $pdf->Output($_SESSION['reports_dir'] . '/' . $PdfFileName, 'F'); $pdf->__destruct(); include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/' . $PdfFileName); $mail->setText(_('Please find herewith our purchase order number') . ' ' . $OrderNo); $mail->setSubject(_('Purchase Order Number') . ' ' . $OrderNo); $mail->addAttachment($attachment, $PdfFileName, 'application/pdf'); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $Success = $mail->send(array($_POST['EmailTo'])); if ($Success == 1) { $title = _('Email a Purchase Order'); include 'includes/header.inc'; echo '<div class="centre"><br /><br /><br />'; prnMsg(_('Purchase Order') . ' ' . $OrderNo . ' ' . _('has been emailed to') . ' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success'); } else { //email failed $title = _('Email a Purchase Order'); include 'includes/header.inc'; echo '<div class="centre"><br /><br /><br />'; prnMsg(_('Emailing Purchase order') . ' ' . $OrderNo . ' ' . _('to') . ' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error');
} /* end of check to see that there was an invoice record to print */ $FromTransNo++; } /* end loop to print invoices */ /* Put the transaction number back as would have been incremented by one after last pass */ $FromTransNo--; if (isset($_GET['Email'])) { //email the invoice to address supplied include 'includes/header.inc'; include 'includes/htmlMimeMail.php'; $FileName = $_SESSION['reports_dir'] . '/' . $_SESSION['DatabaseName'] . '_' . $InvOrCredit . '_' . $FromTransNo . '.pdf'; $pdf->Output($FileName, 'F'); $mail = new htmlMimeMail(); $Attachment = $mail->getFile($FileName); $mail->setText(_('Please find attached') . ' ' . $InvOrCredit . ' ' . $FromTransNo); $mail->SetSubject($InvOrCredit . ' ' . $FromTransNo); $mail->addAttachment($Attachment, $FileName, 'application/pdf'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send(array($_GET['Email'])); } else { $result = SendmailBySmtp($mail, array($_GET['Email'])); } unlink($FileName); //delete the temporary file $Title = _('Emailing') . ' ' . $InvOrCredit . ' ' . _('Number') . ' ' . $FromTransNo; include 'includes/header.inc'; echo '<p>' . $InvOrCredit . ' ' . _('number') . ' ' . $FromTransNo . ' ' . _('has been emailed to') . ' ' . $_GET['Email']; include 'includes/footer.inc'; exit;
include('includes/header.inc'); echo '<p>' . _('There were no transactions to print in the range selected'); include('includes/footer.inc'); exit; }*/ if (isset($_GET['Email'])) { //email the invoice to address supplied include 'includes/header.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $filename = $_SESSION['reports_dir'] . '/Invoice.pdf'; $fp = fopen($_SESSION['reports_dir'] . '/Invoice.pdf', 'wb'); fwrite($fp, $pdfcode); fclose($fp); $attachment = $mail->getFile($filename); $mail->setText(_('Please find attached') . ' ' . $InvOrCredit . ' ' . $_GET['FromTransNo']); $mail->SetSubject($InvOrCredit . ' ' . $_GET['FromTransNo']); $mail->addAttachment($attachment, $filename, 'application/pdf'); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send(array($_GET['Email'])); unlink($filename); //delete the temporary file $title = _('Emailing') . ' ' . $InvOrCredit . ' ' . _('Number') . ' ' . $FromTransNo; include 'includes/header.inc'; echo "<p>{$InvOrCredit} " . _('number') . ' ' . $_GET['FromTransNo'] . ' ' . _('has been emailed to') . ' ' . $_GET['Email']; include 'includes/footer.inc'; exit; } else { header('Content-type: application/pdf'); header('Content-Length: ' . $len); header('Content-Disposition: inline; filename=Customer_trans.pdf');
<?php /* $Revision: 1.7 $ */ /*Now this is not secure so a malicious user could send multiple emails of the report to the intended receipients The intention is that this script is called from cron at intervals defined with a command like: /usr/bin/wget http://localhost/web-erp/MailSalesReport.php The configuration of this script requires the id of the sales analysis report to send and an array of the receipients and the company database to use*/ /*The Sales report to send */ $ReportID = 4; /*The company database to use */ $DatabaseName = 'weberp'; /*The people to receive the emailed report */ $Recipients = array('"Root" <root@localhost>', '"someone else" <*****@*****.**>'); /* ----------------------------------------------------------------------------------------------*/ $AllowAnyone = true; include 'includes/session.inc'; include 'includes/ConstructSQLForUserDefinedSalesReport.inc'; include 'includes/CSVSalesAnalysis.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/SalesAnalysis.csv'); $mail->setText(_('Please find herewith the comma seperated values sales report')); $mail->addAttachment($attachment, 'SalesAnalysis.csv', 'application/csv'); $mail->setSubject(_('Sales Analysis') . ' - ' . _('CSV Format')); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients);
$DbgMsg = _('The following SQL to insert the debtor transaction record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); $DebtorTransID = DB_Last_Insert_ID($db, 'debtortrans', 'id'); $SQL = 'INSERT INTO debtortranstaxes (debtortransid, taxauthid, taxamount) VALUES (' . $DebtorTransID . ', ' . $TaxAuthID . ', ' . $Tax['FXAmount'] / $CurrencyRate . ')'; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); $SQL = 'COMMIT'; $Result = DB_query($SQL, $db); echo _('Invoice number') . ' ' . $InvoiceNo . ' ' . _('processed') . '<BR>'; $EmailText .= "\n" . _('This recurring order was set to produce the invoice automatically on invoice number') . ' ' . $InvoiceNo; } /*end if the recurring order is set to auto invoice */ if (IsEmailAddress($RecurrOrderRow['email'])) { $mail = new htmlMimeMail(); $mail->setText($EmailText); $mail->setSubject(_('Recurring Order Created Advice')); $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] . ">"); $result = $mail->send(array($RecurrOrderRow['email'])); unset($mail); } else { prnMsg(_('No email advice was sent for this order because the location has no email contact defined with a valid email address'), 'warn'); } } /*end while there are recurring orders due to have a new order created */ include 'includes/footer.inc';
function subscriber_sendspam() { if (!$this->haveAccessTo('sendspam-subscribers')) { return $this->showAccessDenied(); } $aData = array(); $aSelectedEmails = func::POSTGET('user_id', false); if (is_array($aSelectedEmails)) { $aSelectedEmails = array_unique($aSelectedEmails); } $sFrom = self::SENDSPAM_FROM; if (func::isPostMethod() || func::POSTGET('submit') == 'send') { $sSubject = func::POSTGET('subject', true); $sBody = func::POSTGET('body', true); if (!$sSubject) { $this->errors->set('no_subject'); } if (!$sBody) { $this->errors->set('no_body'); } if (!is_array($aSelectedEmails) || count($aSelectedEmails) == 0) { $this->errors->set('no_receivers'); } if ($this->errors->no()) { include PATH_CORE . 'mail/htmlMimeMail.php'; @set_time_limit(0); $nCountSuccessfull = 0; $nCountUnsuccessfull = 0; $aEmailsSuccessfull = array(); $oMail = new htmlMimeMail(); $oMail->setSubject($sSubject); $oMail->setFrom($sFrom); $oMail->setText($sBody); for ($i = 0; $i < count($aSelectedEmails); $i++) { if (@$oMail->send(array($aSelectedEmails[$i]))) { $nCountSuccessfull++; $aEmailsSuccessfull[] = $aSelectedEmails[$i]; } else { $nCountUnsuccessfull++; } } if ($nCountUnsuccessfull == 0) { $this->adminRedirect(Errors::SUCCESSFULL, 'subscriber_sendspam'); } else { $this->errors->set('result_of_sendmail', false, 'успешно - ' . $nCountSuccessfull . ' / с ошибками - ' . $nCountUnsuccessfull); //leave only unsuccessfull emails :) $aSelectedEmails = array_diff($aSelectedEmails, $aEmailsSuccessfull); } } $aData = $_REQUEST; } $aSubscribers = $this->db->select('SELECT id, email, name FROM ' . DB_PREFIX . 'subscribers ORDER BY name'); $htmlExistsOptions = ''; $htmlReceiversOptions = ''; for ($i = 0; $i < count($aSubscribers); $i++) { if (!$aSubscribers[$i]['email']) { continue; } $htmlItem = '<option value="' . $aSubscribers[$i]['email'] . '">' . $aSubscribers[$i]['name'] . ' <' . $aSubscribers[$i]['email'] . '> </option>'; if (is_array($aSelectedEmails) && in_array($aSubscribers[$i]['email'], $aSelectedEmails)) { $htmlReceiversOptions .= $htmlItem; } else { $htmlExistsOptions .= $htmlItem; } } $aData['from'] = $sFrom; $this->tplAssign('aData', $aData); $this->tplAssign("exists_values", $htmlExistsOptions); $this->tplAssign("sendtousers_options", $htmlReceiversOptions); return $this->tplFetch('admin.subscriber.sendspam.tpl'); }
$SQL = "UPDATE stockrequestitems\n\t\t\t\t\t\t\t\tSET completed=1\n\t\t\t\t\t\t\tWHERE dispatchid='" . $RequestID . "'\n\t\t\t\t\t\t\t\tAND dispatchitemsid='" . $LineID . "'"; $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); } $Result = DB_Txn_Commit($db); $ConfirmationText = _('An internal stock request for') . ' ' . $StockID . ' ' . _('has been fulfilled from location') . ' ' . $Location . ' ' . _('for a quantity of') . ' ' . locale_number_format($Quantity, $DecimalPlaces); prnMsg($ConfirmationText, 'success'); if ($_SESSION['InventoryManagerEmail'] != '') { $ConfirmationText = $ConfirmationText . ' ' . _('by user') . ' ' . $_SESSION['UserID'] . ' ' . _('at') . ' ' . Date('Y-m-d H:i:s'); $EmailSubject = _('Internal Stock Request Fulfillment for') . ' ' . $StockID; if ($_SESSION['SmtpSetting'] == 0) { mail($_SESSION['InventoryManagerEmail'], $EmailSubject, $ConfirmationText); } else { include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); $mail->setSubject($EmailSubject); $mail->setText($ConfirmationText); $result = SendmailBySmtp($mail, array($_SESSION['InventoryManagerEmail'])); } } } else { $ConfirmationText = _('An internal stock request for') . ' ' . $StockID . ' ' . _('has been fulfilled from location') . ' ' . $Location . ' ' . _('for a quantity of') . ' ' . locale_number_format($Quantity, $DecimalPlaces) . ' ' . _('cannot be created as there is insufficient stock and your system is configured to not allow negative stocks'); prnMsg($ConfirmationText, 'warn'); } // Check if request can be closed and close if done. if (isset($RequestID)) { $SQL = "SELECT dispatchid\n\t\t\t\t\t\tFROM stockrequestitems\n\t\t\t\t\t\tWHERE dispatchid='" . $RequestID . "'\n\t\t\t\t\t\t\tAND completed=0"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result) == 0) { $SQL = "UPDATE stockrequest\n\t\t\t\t\t\tSET closed=1\n\t\t\t\t\tWHERE dispatchid='" . $RequestID . "'"; $Result = DB_query($SQL, $db); }
$Title = _('Inventory Valuation') . ' - ' . _('Problem Report'); include 'includes/header.inc'; prnMsg(_('There are no members of the Sales Analysis Report Recipients email group'), 'warn'); include 'includes/footer.inc'; exit; } include 'includes/ConstructSQLForUserDefinedSalesReport.inc'; include 'includes/PDFSalesAnalysis.inc'; include 'includes/htmlMimeMail.php'; $mail = new htmlMimeMail(); if ($Counter > 0) { $pdf->Output($_SESSION['reports_dir'] . '/SalesAnalysis_' . date('Y-m-d') . '.pdf', 'F'); //save to file $pdf->__destruct(); $attachment = $mail->getFile($_SESSION['reports_dir'] . '/SalesAnalysis_' . date('Y-m-d') . '.pdf'); $mail->setText(_('Please find herewith sales report')); $mail->SetSubject(_('Sales Analysis Report')); $mail->addAttachment($attachment, 'SalesAnalysis_' . date('Y-m-d') . '.pdf', 'application/pdf'); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients); } } else { $mail->setText(_('Error running automated sales report number') . ' ' . $ReportID); if ($_SESSION['SmtpSetting'] == 0) { $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); $result = $mail->send($Recipients); } else { $result = SendmailBySmtp($mail, $Recipients);