function send_message($msgid, $cid, $rmail, $rname, $subject, $body, $host = null, $port = null, $user = null, $pass = null, $auth = null) { global $LMS, $DB, $mail_from; $DB->Execute("INSERT INTO messageitems\n\t\t(messageid, customerid, destination, status)\n\t\tVALUES (?, ?, ?, ?)", array($msgid, $cid, $rmail, 1)); $headers = array('From' => $mail_from, 'To' => qp_encode($rname) . ' <' . $rmail . '>', 'Subject' => $subject); $result = $LMS->SendMail($rmail, $headers, $body, null, $host, $port, $user, $pass, $auth); $query = "UPDATE messageitems\n\t\tSET status = ?, lastdate = ?NOW?, error = ?\n\t\tWHERE messageid = ? AND customerid = ?"; if (is_string($result)) { $DB->Execute($query, array(3, $result, $msgid, $cid)); } else { // MSG_SENT $DB->Execute($query, array($result, null, $msgid, $cid)); } }
function send_mail($msgid, $cid, $rmail, $rname, $subject, $body) { global $LMS, $DB, $mail_from, $notify_email; $DB->Execute("INSERT INTO messageitems\n\t\t(messageid, customerid, destination, status)\n\t\tVALUES (?, ?, ?, ?)", array($msgid, $cid, $rmail, 1)); $msgitemid = $DB->GetLastInsertID('messageitems'); $headers = array('From' => $mail_from, 'To' => qp_encode($rname) . " <{$rmail}>", 'Subject' => $subject); if (!empty($notify_email)) { $headers['Cc'] = $notify_email; } $result = $LMS->SendMail($rmail, $headers, $body); $query = "UPDATE messageitems\n\t\tSET status = ?, lastdate = ?NOW?, error = ?\n\t\tWHERE messageid = ? AND customerid = ? AND id = ?"; if (is_string($result)) { $DB->Execute($query, array(3, $result, $msgid, $cid, $msgitemid)); } else { // MSG_SENT $DB->Execute($query, array($result, null, $msgid, $cid, $msgitemid)); } }
function send_mail_to_user($rmail, $rname, $subject, $body) { global $LMS, $mail_from, $notify_email; global $host, $port, $user, $pass, $auth; $headers = array('From' => $mail_from, 'To' => qp_encode($rname) . " <{$rmail}>", 'Subject' => $subject); if (!empty($notify_email)) { $headers['Cc'] = $notify_email; } $result = $LMS->SendMail($rmail, $headers, $body, null, $host, $port, $user, $pass, $auth); }
function send_email($msgid, $cid, $rmail, $rname, $subject, $body) { global $LMS, $DB, $mail_from, $footer; $DB->Execute("INSERT INTO messageitems\n (messageid, customerid, destination, status)\n VALUES (?, ?, ?, ?)", array($msgid, $cid, $rmail, 1)); #echo "$msgid, $cid, $rmail, 1\n"; $headers = array('From' => $mail_from, 'To' => qp_encode($rname) . ' <' . $rmail . '>', 'Subject' => $subject, 'X-msgid' => $DB->GetLastInsertID('messageitems'), 'X-customerid' => $cid, 'Return-receipt-to' => $mail_from); if ($footer != '') { $body .= "\n\n" . $footer . "\n"; } $result = $LMS->SendMail($rmail, $headers, $body); $query = "UPDATE messageitems\n SET status = ?, lastdate = ?NOW?, error = ?\n WHERE messageid = ? AND customerid = ?"; if (is_string($result)) { $DB->Execute($query, array(3, $result, $msgid, $cid)); } else { // MSG_SENT $DB->Execute($query, array($result, null, $msgid, $cid)); } return $result; }
$invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z')); $body = preg_replace('/%invoice/', $invoice_number, $body); $body = preg_replace('/%balance/', $LMS->GetCustomerBalance($doc['customerid']), $body); $day = sprintf("%02d", $day); $month = sprintf("%02d", $month); $year = sprintf("%04d", $year); $body = preg_replace('/%today/', $year . "-" . $month . "-" . $day, $body); $body = str_replace('\\n', "\n", $body); $subject = preg_replace('/%invoice/', $invoice_number, $subject); $filename = preg_replace('/%docid/', $doc['id'], $invoice_filename); $doc['name'] = '"' . $doc['name'] . '"'; $mailto = array(); $mailto_qp_encoded = array(); foreach (explode(',', $custemail) as $email) { $mailto[] = $doc['name'] . " <{$email}>"; $mailto_qp_encoded[] = qp_encode($doc['name']) . " <{$email}>"; } $mailto = implode(', ', $mailto); $mailto_qp_encoded = implode(', ', $mailto_qp_encoded); if (!$quiet || $test) { printf("Invoice No. {$invoice_number} for {$mailto}" . PHP_EOL); } if (!$test) { $headers = array('From' => $from, 'To' => $mailto_qp_encoded, 'Subject' => $subject); if (!empty($notify_email)) { $headers['Cc'] = $notify_email; } $res = $LMS->SendMail($custemail . ',' . $notify_email, $headers, $body, array(0 => array('content_type' => $ftype, 'filename' => $filename . '.' . $fext, 'data' => $res)), $host, $port, $user, $pass, $auth); if (is_string($res)) { fprintf(STDERR, "Error sending mail: {$res}" . PHP_EOL); }
$invoice_number = !empty($doc['template']) ? $doc['template'] : '%N/LMS/%Y'; $body = $mail_body; $subject = $mail_subject; $invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z')); $body = preg_replace('/%invoice/', $invoice_number, $body); $body = preg_replace('/%balance/', $LMS->GetCustomerBalance($doc['customerid']), $body); $day = sprintf("%02d", $day); $month = sprintf("%02d", $month); $year = sprintf("%04d", $year); $body = preg_replace('/%today/', $year . "-" . $month . "-" . $day, $body); $body = str_replace('\\n', "\n", $body); $subject = preg_replace('/%invoice/', $invoice_number, $subject); $filename = preg_replace('/%docid/', $doc['id'], $invoice_filename); if (!$quiet || $test) { printf("Invoice No. {$invoice_number} for " . $doc['name'] . " <{$custemail}>\n"); } if (!$test) { $headers = array('From' => $from, 'To' => qp_encode($doc['name']) . ' <' . $custemail . '>', 'Subject' => $subject); if (!empty($notify_email)) { $headers['Cc'] = $notify_email; } $res = $LMS->SendMail($custemail . ',' . $notify_email, $headers, $body, array(0 => array('content_type' => $ftype, 'filename' => $filename . '.' . $fext, 'data' => $res))); if (is_string($res)) { fprintf(STDERR, "Error sending mail: {$res}\n"); } } } } } curl_close($ch); unlink(COOKIE_FILE);
public function SendInvoices($docs, $type, $params) { extract($params); if ($type == 'frontend') { $eol = '<br>'; } else { $eol = PHP_EOL; } $month = sprintf('%02d', intval(date('m', $currtime))); $day = sprintf('%02d', intval(date('d', $currtime))); $year = sprintf('%04d', intval(date('Y', $currtime))); if ($invoice_filetype == 'pdf') { $invoice_ftype = 'application/pdf'; $invoice_fext = 'pdf'; $pdf_type = ConfigHelper::getConfig('invoices.pdf_type', 'tcpdf'); $pdf_type = ucwords($pdf_type); $invoice_classname = 'LMS' . $pdf_type . 'Invoice'; } else { $invoice_ftype = 'text/html'; $invoice_fext = 'html'; $invoice_classname = 'LMSHtmlInvoice'; } if ($dnote_filetype == 'pdf') { $dnote_ftype = 'application/pdf'; $dnote_fext = 'pdf'; $dnote_classname = 'LMSTcpdfDebitNote'; } else { $dnote_ftype = 'text/html'; $dnote_fext = 'html'; $dnote_classname = 'LMSHtmlDebitNote'; } $from = $sender_email; if (!empty($sender_name)) { $from = "{$sender_name} <{$from}>"; } foreach ($docs as $doc) { if ($doc['doctype'] == DOC_DNOTE) { if ($dnote_filetype == 'pdf') { $document = new $dnote_classname(trans('Notes')); } else { $document = new $dnote_classname($SMARTY); } $invoice = $this->GetNoteContent($doc['id']); } else { if ($invoice_filetype == 'pdf') { $document = new $invoice_classname(trans('Invoices')); } else { $document = new $invoice_classname($SMARTY); } $invoice = $this->GetInvoiceContent($doc['id']); } $invoice['type'] = trans('ORIGINAL'); $document->Draw($invoice); $res = $document->WriteToString(); $custemail = !empty($debug_email) ? $debug_email : $doc['email']; $invoice_number = !empty($doc['template']) ? $doc['template'] : '%N/LMS/%Y'; if (!is_null($mail_body)) { if (is_readable($mail_body) && $mail_body[0] == DIRECTORY_SEPARATOR) { $body = file_get_contents($mail_body); } else { $body = $mail_body; } } $subject = $mail_subject; $invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z')); $body = preg_replace('/%invoice/', $invoice_number, $body); $body = preg_replace('/%balance/', $this->GetCustomerBalance($doc['customerid']), $body); $body = preg_replace('/%today/', $year . '-' . $month . '-' . $day, $body); $body = str_replace('\\n', "\n", $body); $subject = preg_replace('/%invoice/', $invoice_number, $subject); $filename = preg_replace('/%docid/', $doc['id'], $doc['doctype'] == DOC_DNOTE ? $dnote_filename : $invoice_filename); $filename = str_replace('%number', $invoice_number, $filename); $filename = preg_replace('/[^[:alnum:]_\\.]/i', '_', $filename); $doc['name'] = '"' . $doc['name'] . '"'; $mailto = array(); $mailto_qp_encoded = array(); foreach (explode(',', $custemail) as $email) { $mailto[] = $doc['name'] . " <{$email}>"; $mailto_qp_encoded[] = qp_encode($doc['name']) . " <{$email}>"; } $mailto = implode(', ', $mailto); $mailto_qp_encoded = implode(', ', $mailto_qp_encoded); if (!$quiet || $test) { switch ($doc['doctype']) { case DOC_DNOTE: $msg = trans('Debit Note No. $a for $b', $invoice_number, $mailto); break; case DOC_CNOTE: $msg = trans('Credit Note No. $a for $b', $invoice_number, $mailto); break; case DOC_INVOICE: $msg = trans('Invoice No. $a for $b', $invoice_number, $mailto); break; } if ($type == 'frontend') { echo htmlspecialchars($msg) . $eol; flush(); ob_flush(); } else { echo $msg . $eol; } } if (!$test) { $files = array(); $files[] = array('content_type' => $doc['doctype'] == DOC_DNOTE ? $dnote_ftype : $invoice_ftype, 'filename' => $filename . '.' . ($doc['doctype'] == DOC_DNOTE ? $dnote_fext : $invoice_fext), 'data' => $res); if ($extrafile) { $files[] = array('content_type' => mime_content_type($extrafile), 'filename' => basename($extrafile), 'data' => file_get_contents($extrafile)); } $headers = array('From' => empty($dsn_email) ? $from : $dsn_email, 'To' => $mailto_qp_encoded, 'Subject' => $subject, 'Reply-To' => empty($reply_email) ? $sender_email : $reply_email); if (!empty($mdn_email)) { $headers['Return-Receipt-To'] = $mdn_email; $headers['Disposition-Notification-To'] = $mdn_email; } if (!empty($notify_email)) { $headers['Cc'] = $notify_email; } if ($add_message) { $this->DB->Execute('INSERT INTO messages (subject, body, cdate, type, userid) VALUES (?, ?, ?NOW?, ?, ?)', array($subject, $body, MSG_MAIL, empty($this->AUTH) ? 0 : $this->AUTH->id)); $msgid = $this->DB->GetLastInsertID('messages'); foreach (explode(',', $custemail) as $email) { $this->DB->Execute('INSERT INTO messageitems (messageid, customerid, destination, lastdate, status) VALUES (?, ?, ?, ?NOW?, ?)', array($msgid, $doc['customerid'], $email, MSG_NEW)); $msgitemid = $this->DB->GetLastInsertID('messageitems'); if (!isset($msgitems[$doc['customerid']])) { $msgitems[$doc['customerid']] = array(); } $msgitems[$doc['customerid']][$email] = $msgitemid; } } foreach (explode(',', $custemail) as $email) { if ($add_message && (!empty($dsn_email) || !empty($mdn_email))) { if (!empty($dsn_email)) { $headers['Delivery-Status-Notification-To'] = true; } $headers['X-LMS-Message-Item-Id'] = $msgitems[$doc['customerid']][$email]; } $res = $this->SendMail($email . ',' . $notify_email, $headers, $body, $files, $smtp_host, $smtp_port, $smtp_user, $smtp_pass, $smtp_auth); if (is_string($res)) { $msg = trans('Error sending mail: $a', $res); if ($type == 'backend') { fprintf(STDERR, $msg . $eol); } else { echo '<span class="red">' . htmlspecialchars($msg) . '</span>' . $eol; flush(); } $status = MSG_ERROR; } else { $status = MSG_SENT; $res = NULL; } if ($add_message) { $this->DB->Execute('UPDATE messageitems SET status = ?, error = ? WHERE id = ?', array($status, $res, $msgitems[$doc['customerid']][$email])); } } } } }
function SendMail($recipients, $headers, $body, $files = NULL) { @(include_once 'Mail.php'); if (!class_exists('Mail')) { return trans('Can\'t send message. PEAR::Mail not found!'); } $params['host'] = $this->CONFIG['mail']['smtp_host']; $params['port'] = $this->CONFIG['mail']['smtp_port']; if (!empty($this->CONFIG['mail']['smtp_username'])) { $params['auth'] = !empty($this->CONFIG['mail']['smtp_auth_type']) ? $this->CONFIG['mail']['smtp_auth_type'] : true; $params['username'] = $this->CONFIG['mail']['smtp_username']; $params['password'] = $this->CONFIG['mail']['smtp_password']; } else { $params['auth'] = false; } $headers['X-Mailer'] = 'LMS-' . $this->_version; $headers['X-Remote-IP'] = $_SERVER['REMOTE_ADDR']; $headers['X-HTTP-User-Agent'] = $_SERVER['HTTP_USER_AGENT']; $headers['Mime-Version'] = '1.0'; $headers['Subject'] = qp_encode($headers['Subject']); if (!empty($this->CONFIG['mail']['debug_email'])) { $recipients = $this->CONFIG['mail']['debug_email']; $headers['To'] = '<' . $recipients . '>'; } if (empty($headers['Date'])) { $headers['Date'] = date('r'); } if ($files) { $boundary = '-LMS-' . str_replace(' ', '.', microtime()); $headers['Content-Type'] = "multipart/mixed;\n boundary=\"" . $boundary . '"'; $buf = "\nThis is a multi-part message in MIME format.\n\n"; $buf .= '--' . $boundary . "\n"; $buf .= "Content-Type: text/plain; charset=UTF-8\n\n"; $buf .= $body . "\n"; while (list(, $chunk) = each($files)) { $buf .= '--' . $boundary . "\n"; $buf .= "Content-Transfer-Encoding: base64\n"; $buf .= "Content-Type: " . $chunk['content_type'] . "; name=\"" . $chunk['filename'] . "\"\n"; $buf .= "Content-Description:\n"; $buf .= "Content-Disposition: attachment; filename=\"" . $chunk['filename'] . "\"\n\n"; $buf .= chunk_split(base64_encode($chunk['data']), 60, "\n"); } $buf .= '--' . $boundary . '--'; } else { $headers['Content-Type'] = 'text/plain; charset=UTF-8'; $buf = $body; } $error = $mail_object =& Mail::factory('smtp', $params); // if (PEAR::isError($error)) if (is_a($error, 'PEAR::_Error')) { return $error->getMessage(); } $error = $mail_object->send($recipients, $headers, $buf); // if (PEAR::isError($error)) if (is_a($error, 'PEAR::_Error')) { return $error->getMessage(); } else { return MSG_SENT; } }
foreach ($recipients[$key]['destination'] as $destination) { $DB->Execute('INSERT INTO messageitems (messageid, customerid, destination, status) VALUES (?, ?, ?, ?)', array($msgid, isset($row['id']) ? $row['id'] : 0, $destination, MSG_NEW)); } } $DB->CommitTrans(); if ($message['type'] == MSG_MAIL) { if (empty($files)) { $files = null; } $debug_email = ConfigHelper::getConfig('mail.debug_email'); if (!empty($debug_email)) { echo '<B>' . trans('Warning! Debug mode (using address $a).', ConfigHelper::getConfig('mail.debug_email')) . '</B><BR>'; } $headers['From'] = qp_encode($message['from']) . ' <' . $message['sender'] . '>'; $headers['Subject'] = $message['subject']; $headers['Reply-To'] = $headers['From']; if (isset($message['copytosender'])) { $headers['Cc'] = $headers['From']; } if (!empty($message['wysiwyg'])) { $headers['X-LMS-Format'] = 'html'; } } elseif ($message['type'] != MSG_WWW) { $debug_phone = ConfigHelper::getConfig('sms.debug_phone'); if (!empty($debug_phone)) { echo '<B>' . trans('Warning! Debug mode (using phone $a).', $debug_phone) . '</B><BR>'; } } foreach ($recipients as $key => $row) {
public function SendMail($recipients, $headers, $body, $files = NULL, $host = null, $port = null, $user = null, $pass = null, $auth = null, $persist = null) { @(include_once 'Mail.php'); if (!class_exists('Mail')) { return trans('Can\'t send message. PEAR::Mail not found!'); } $persist = is_null($persist) ? ConfigHelper::getConfig('mail.smtp_persist', true) : $persist; if (!is_object($this->mail_object) || !$persist) { $params['host'] = !$host ? ConfigHelper::getConfig('mail.smtp_host') : $host; $params['port'] = !$port ? ConfigHelper::getConfig('mail.smtp_port') : $port; $smtp_username = ConfigHelper::getConfig('mail.smtp_username'); if (!empty($smtp_username) || $user) { $params['auth'] = !$auth ? ConfigHelper::getConfig('mail.smtp_auth_type', true) : $auth; $params['username'] = !$user ? $smtp_username : $user; $params['password'] = !$pass ? ConfigHelper::getConfig('mail.smtp_password') : $pass; } else { $params['auth'] = false; } $params['persist'] = $persist; $error = $this->mail_object =& Mail::factory('smtp', $params); //if (PEAR::isError($error)) if (is_a($error, 'PEAR_Error')) { return $error->getMessage(); } } $headers['X-Mailer'] = 'LMS-' . $this->_version; if (!empty($_SERVER['REMOTE_ADDR'])) { $headers['X-Remote-IP'] = $_SERVER['REMOTE_ADDR']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $headers['X-HTTP-User-Agent'] = $_SERVER['HTTP_USER_AGENT']; } $headers['Mime-Version'] = '1.0'; $headers['Subject'] = qp_encode($headers['Subject']); $debug_email = ConfigHelper::getConfig('mail.debug_email'); if (!empty($debug_email)) { $recipients = ConfigHelper::getConfig('mail.debug_email'); $headers['To'] = '<' . $recipients . '>'; } if (empty($headers['Date'])) { $headers['Date'] = date('r'); } if ($files || $headers['X-LMS-Format'] == 'html') { $boundary = '-LMS-' . str_replace(' ', '.', microtime()); $headers['Content-Type'] = "multipart/mixed;\n boundary=\"" . $boundary . '"'; $buf = "\nThis is a multi-part message in MIME format.\n\n"; $buf .= '--' . $boundary . "\n"; $buf .= "Content-Type: text/" . ($headers['X-LMS-Format'] == 'html' ? "html" : "plain") . "; charset=UTF-8\n\n"; $buf .= $body . "\n"; if ($files) { while (list(, $chunk) = each($files)) { $buf .= '--' . $boundary . "\n"; $buf .= "Content-Transfer-Encoding: base64\n"; $buf .= "Content-Type: " . $chunk['content_type'] . "; name=\"" . $chunk['filename'] . "\"\n"; $buf .= "Content-Description:\n"; $buf .= "Content-Disposition: attachment; filename=\"" . $chunk['filename'] . "\"\n\n"; $buf .= chunk_split(base64_encode($chunk['data']), 60, "\n"); } } $buf .= '--' . $boundary . '--'; } else { $headers['Content-Type'] = 'text/plain; charset=UTF-8'; $buf = $body; } $error = $this->mail_object->send($recipients, $headers, $buf); //if (PEAR::isError($error)) if (is_a($error, 'PEAR_Error')) { return $error->getMessage(); } else { return MSG_SENT; } }
if (isset(Server::$Operators[$id])) { $sysid = $_GET["intid"]; if (!empty(Server::$Operators[$id]->Profile)) { header("Content-Type: application/vcard;"); header("Content-Disposition: attachment; filename=" . utf8_decode($sysid) . ".vcf"); $vcard = IOStruct::GetFile("./templates/vcard.tpl"); $vcard = str_replace("<!--Name-->", qp_encode(Server::$Operators[$id]->Profile->Name), $vcard); $vcard = str_replace("<!--Firstname-->", qp_encode(Server::$Operators[$id]->Profile->Firstname), $vcard); $vcard = str_replace("<!--Company-->", qp_encode(Server::$Operators[$id]->Profile->Company), $vcard); $vcard = str_replace("<!--Comments-->", qp_encode(Server::$Operators[$id]->Profile->Comments), $vcard); $vcard = str_replace("<!--Phone-->", qp_encode(Server::$Operators[$id]->Profile->Phone), $vcard); $vcard = str_replace("<!--Fax-->", qp_encode(Server::$Operators[$id]->Profile->Fax), $vcard); $vcard = str_replace("<!--Street-->", qp_encode(Server::$Operators[$id]->Profile->Street), $vcard); $vcard = str_replace("<!--City-->", qp_encode(Server::$Operators[$id]->Profile->City), $vcard); $vcard = str_replace("<!--ZIP-->", qp_encode(Server::$Operators[$id]->Profile->ZIP), $vcard); $vcard = str_replace("<!--Country-->", qp_encode(Server::$Operators[$id]->Profile->Country), $vcard); $vcard = str_replace("<!--URL-->", qp_encode("http://" . Server::$Configuration->File["gl_host"] . str_replace("visitcard.php", FILE_CHAT . "?intid=" . Encoding::Base64UrlEncode($_GET["intid"]), htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES, "UTF-8"))), $vcard); $vcard = str_replace("<!--Languages-->", qp_encode(Server::$Operators[$id]->Profile->Languages), $vcard); $vcard = str_replace("<!--Email-->", Server::$Operators[$id]->Profile->Email, $vcard); $vcard = str_replace("<!--Gender-->", qp_encode(Server::$Operators[$id]->Profile->Gender), $vcard); $vcard = str_replace("<!--Picture-->", !empty(Server::$Operators[$id]->ProfilePicture) ? "\r\nPHOTO;TYPE=JPEG;ENCODING=BASE64:\r\n" . Server::$Operators[$id]->ProfilePicture : "", $vcard); exit($vcard); } } } function qp_encode($string) { $string = str_replace(array('%20', '%0D%0A', '%'), array(' ', "\r\n", '='), rawurlencode(utf8_decode($string))); $string = preg_replace('/[^\\r\\n]{73}[^=\\r\\n]{2}/', "\$0=\r\n", $string); return $string; }
public function SendMail($recipients, $headers, $body, $files = NULL, $host = null, $port = null, $user = null, $pass = null, $auth = null, $persist = null) { $persist = is_null($persist) ? ConfigHelper::getConfig('mail.smtp_persist', true) : $persist; if (ConfigHelper::getConfig('mail.backend') == 'pear') { @(include_once 'Mail.php'); if (!class_exists('Mail')) { return trans('Can\'t send message. PEAR::Mail not found!'); } if (!is_object($this->mail_object) || !$persist) { $params['host'] = !$host ? ConfigHelper::getConfig('mail.smtp_host') : $host; $params['port'] = !$port ? ConfigHelper::getConfig('mail.smtp_port') : $port; $smtp_username = ConfigHelper::getConfig('mail.smtp_username'); if (!empty($smtp_username) || $user) { $params['auth'] = !$auth ? ConfigHelper::getConfig('mail.smtp_auth_type', true) : $auth; $params['username'] = !$user ? $smtp_username : $user; $params['password'] = !$pass ? ConfigHelper::getConfig('mail.smtp_password') : $pass; } else { $params['auth'] = false; } $params['persist'] = $persist; $error = $this->mail_object =& Mail::factory('smtp', $params); //if (PEAR::isError($error)) if (is_a($error, 'PEAR_Error')) { return $error->getMessage(); } } $headers['X-Mailer'] = 'LMS-' . $this->_version; if (!empty($_SERVER['REMOTE_ADDR'])) { $headers['X-Remote-IP'] = $_SERVER['REMOTE_ADDR']; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $headers['X-HTTP-User-Agent'] = $_SERVER['HTTP_USER_AGENT']; } $headers['Mime-Version'] = '1.0'; $headers['Subject'] = qp_encode($headers['Subject']); $debug_email = ConfigHelper::getConfig('mail.debug_email'); if (!empty($debug_email)) { $recipients = ConfigHelper::getConfig('mail.debug_email'); $headers['To'] = '<' . $recipients . '>'; } if (empty($headers['Date'])) { $headers['Date'] = date('r'); } if ($files || $headers['X-LMS-Format'] == 'html') { $boundary = '-LMS-' . str_replace(' ', '.', microtime()); $headers['Content-Type'] = "multipart/mixed;\n boundary=\"" . $boundary . '"'; $buf = "\nThis is a multi-part message in MIME format.\n\n"; $buf .= '--' . $boundary . "\n"; $buf .= "Content-Type: text/" . ($headers['X-LMS-Format'] == 'html' ? "html" : "plain") . "; charset=UTF-8\n\n"; $buf .= $body . "\n"; if ($files) { while (list(, $chunk) = each($files)) { $buf .= '--' . $boundary . "\n"; $buf .= "Content-Transfer-Encoding: base64\n"; $buf .= "Content-Type: " . $chunk['content_type'] . "; name=\"" . $chunk['filename'] . "\"\n"; $buf .= "Content-Description:\n"; $buf .= "Content-Disposition: attachment; filename=\"" . $chunk['filename'] . "\"\n\n"; $buf .= chunk_split(base64_encode($chunk['data']), 60, "\n"); } } $buf .= '--' . $boundary . '--'; } else { $headers['Content-Type'] = 'text/plain; charset=UTF-8'; $buf = $body; } $error = $this->mail_object->send($recipients, $headers, $buf); //if (PEAR::isError($error)) if (is_a($error, 'PEAR_Error')) { return $error->getMessage(); } else { return MSG_SENT; } } elseif (ConfigHelper::getConfig('mail.backend') == 'phpmailer') { $this->mail_object = new PHPMailer(); $this->mail_object->isSMTP(); $this->mail_object->SMTPKeepAlive = $persist; $this->mail_object->Host = !$host ? ConfigHelper::getConfig('mail.smtp_host') : $host; $this->mail_object->Port = !$port ? ConfigHelper::getConfig('mail.smtp_port') : $port; $smtp_username = ConfigHelper::getConfig('mail.smtp_username'); if (!empty($smtp_username) || $user) { $this->mail_object->Username = !$user ? $smtp_username : $user; $this->mail_object->Password = !$pass ? ConfigHelper::getConfig('mail.smtp_password') : $pass; $this->mail_object->SMTPAuth = !$auth ? ConfigHelper::getConfig('mail.smtp_auth_type', true) : $auth; $this->mail_object->SMTPSecure = !$auth ? ConfigHelper::getConfig('mail.smtp_secure', true) : $auth; } $this->mail_object->XMailer = 'LMS-' . $this->_version; if (!empty($_SERVER['REMOTE_ADDR'])) { $this->mail_object->addCustomHeader('X-Remote-IP: ' . $_SERVER['REMOTE_ADDR']); } if (isset($_SERVER['HTTP_USER_AGENT'])) { $this->mail_object->addCustomHeader('X-HTTP-User-Agent: ' . $_SERVER['HTTP_USER_AGENT']); } if (isset($headers['X-LMS-Message-Item-Id'])) { $this->mail_object->addCustomHeader('X-LMS-Message-Item-Id: ' . $headers['X-LMS-Message-Item-Id']); } if (isset($headers['Disposition-Notification-To'])) { $this->mail_object->ConfirmReadingTo = $headers['Disposition-Notification-To']; } elseif (isset($headers['Return-Receipt-To'])) { $this->mail_object->ConfirmReadingTo = $headers['Return-Receipt-To']; } $this->mail_object->Dsn = isset($headers['Delivery-Status-Notification-To']); preg_match('/^(.+) <([a-z0-9_\\.-]+@[\\da-z\\.-]+\\.[a-z\\.]{2,6})>$/A', $headers['From'], $from); $this->mail_object->setFrom($from[2], trim($from[1], "\"")); $this->mail_object->addReplyTo($headers['Reply-To']); $this->mail_object->CharSet = 'UTF-8'; $this->mail_object->Subject = $headers['Subject']; $debug_email = ConfigHelper::getConfig('mail.debug_email'); if (!empty($debug_email)) { $this->mail_object->SMTPDebug = 2; $recipients = ConfigHelper::getConfig('mail.debug_email'); } if (empty($headers['Date'])) { $headers['Date'] = date('r'); } if ($files) { while (list(, $chunk) = each($files)) { $this->mail_object->AddStringAttachment($chunk['data'], $chunk['filename'], 'base64', $chunk['content_type']); } } if ($headers['X-LMS-Format'] == 'html') { $this->mail_object->isHTML(true); $this->mail_object->AltBody = trans("To view the message, please use an HTML compatible email viewer"); $this->mail_object->msgHTML($body); } else { $this->mail_object->isHTML(false); $this->mail_object->Body = $body; } foreach (explode(",", $recipients) as $recipient) { $this->mail_object->addAddress($recipient); } if (!$this->mail_object->Send()) { return "Mailer Error: " . $this->mail_object->ErrorInfo; } else { return MSG_SENT; } } }
if (isset($INTERNAL[$id])) { $sysid = $_GET["intid"]; if (!empty($INTERNAL[$id]->Profile)) { header("Content-Type: application/vcard;"); header("Content-Disposition: attachment; filename=" . utf8_decode($sysid) . ".vcf"); $vcard = getFile("./templates/vcard.tpl"); $vcard = str_replace("<!--Name-->", qp_encode($INTERNAL[$id]->Profile->Name), $vcard); $vcard = str_replace("<!--Firstname-->", qp_encode($INTERNAL[$id]->Profile->Firstname), $vcard); $vcard = str_replace("<!--Company-->", qp_encode($INTERNAL[$id]->Profile->Company), $vcard); $vcard = str_replace("<!--Comments-->", qp_encode($INTERNAL[$id]->Profile->Comments), $vcard); $vcard = str_replace("<!--Phone-->", qp_encode($INTERNAL[$id]->Profile->Phone), $vcard); $vcard = str_replace("<!--Fax-->", qp_encode($INTERNAL[$id]->Profile->Fax), $vcard); $vcard = str_replace("<!--Street-->", qp_encode($INTERNAL[$id]->Profile->Street), $vcard); $vcard = str_replace("<!--City-->", qp_encode($INTERNAL[$id]->Profile->City), $vcard); $vcard = str_replace("<!--ZIP-->", qp_encode($INTERNAL[$id]->Profile->ZIP), $vcard); $vcard = str_replace("<!--Country-->", qp_encode($INTERNAL[$id]->Profile->Country), $vcard); $vcard = str_replace("<!--URL-->", qp_encode("http://" . $CONFIG["gl_host"] . str_replace("visitcard.php", FILE_CHAT . "?intid=" . base64UrlEncode($_GET["intid"]), htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES, "UTF-8"))), $vcard); $vcard = str_replace("<!--Languages-->", qp_encode($INTERNAL[$id]->Profile->Languages), $vcard); $vcard = str_replace("<!--Email-->", $INTERNAL[$id]->Profile->Email, $vcard); $vcard = str_replace("<!--Gender-->", qp_encode($INTERNAL[$id]->Profile->Gender), $vcard); $vcard = str_replace("<!--Picture-->", !empty($INTERNAL[$id]->ProfilePicture) ? "\r\nPHOTO;TYPE=JPEG;ENCODING=BASE64:\r\n" . $INTERNAL[$id]->ProfilePicture : "", $vcard); exit($vcard); } } } function qp_encode($string) { $string = str_replace(array('%20', '%0D%0A', '%'), array(' ', "\r\n", '='), rawurlencode(utf8_decode($string))); $string = preg_replace('/[^\\r\\n]{73}[^=\\r\\n]{2}/', "\$0=\r\n", $string); return $string; }