$length))
- {
- $space_left = $length - strlen($buf) - 1;
- if ($e != 0)
- {
- if ($space_left > 20)
- {
- $len = $space_left;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
- $buf .= " " . $part;
- $message .= $buf . sprintf("=%s", $this->LE);
- }
- else
- {
- $message .= $buf . $soft_break;
- }
- $buf = "";
- }
- while (strlen($word) > 0)
- {
- $len = $length;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
-
- if (strlen($word) > 0)
- $message .= $part . sprintf("=%s", $this->LE);
- else
- $buf = $part;
- }
- }
- else
- {
- $buf_o = $buf;
- $buf .= ($e == 0) ? $word : (" " . $word);
-
- if (strlen($buf) > $length and $buf_o != "")
- {
- $message .= $buf_o . $soft_break;
- $buf = $word;
- }
- }
- }
- $message .= $buf . $this->LE;
- }
-
- return $message;
- }
-
- /**
- * Set the body wrapping.
- * @access private
- * @return void
- */
- function SetWordWrap() {
- if($this->WordWrap < 1)
- return;
-
- switch($this->message_type)
- {
- case "alt":
- // fall through
- case "alt_attachments":
- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
- break;
- default:
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
- break;
- }
- }
-
- /**
- * Assembles message header.
- * @access private
- * @return string
- */
- function CreateHeader() {
- $result = "";
-
- // Set the boundaries
- $uniq_id = md5(uniqid(time()));
- $this->boundary[1] = "b1_" . $uniq_id;
- $this->boundary[2] = "b2_" . $uniq_id;
-
- $result .= $this->HeaderLine("Date", $this->RFCDate());
- if($this->Sender == "")
- $result .= $this->HeaderLine("Return-Path", trim($this->From));
- else
- $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
-
- // To be created automatically by mail()
- if($this->Mailer != "mail")
- {
- if(count($this->to) > 0)
- $result .= $this->AddrAppend("To", $this->to);
- else if (count($this->cc) == 0)
- $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
- if(count($this->cc) > 0)
- $result .= $this->AddrAppend("Cc", $this->cc);
- }
-
- $from = array();
- $from[0][0] = trim($this->From);
- $from[0][1] = $this->FromName;
- $result .= $this->AddrAppend("From", $from);
-
- // sendmail and mail() extract Bcc from the header before sending
- if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
- $result .= $this->AddrAppend("Bcc", $this->bcc);
-
- if(count($this->ReplyTo) > 0)
- $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
-
- // mail() sets the subject itself
- if($this->Mailer != "mail")
- $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
-
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
- $result .= $this->HeaderLine("X-Priority", $this->Priority);
- $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
-
- if($this->ConfirmReadingTo != "")
- {
- $result .= $this->HeaderLine("Disposition-Notification-To",
- "<" . trim($this->ConfirmReadingTo) . ">");
- }
-
- // Add custom vtiger_headers
- for($index = 0; $index < count($this->CustomHeader); $index++)
- {
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
- $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
- }
- $result .= $this->HeaderLine("MIME-Version", "1.0");
-
- switch($this->message_type)
- {
- case "plain":
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
- $result .= sprintf("Content-Type: %s; charset=\"%s\"",
- $this->ContentType, $this->CharSet);
- break;
- case "attachments":
- // fall through
- case "alt_attachments":
- if($this->InlineImageExists())
- {
- $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
- "multipart/related", $this->LE, $this->LE,
- $this->boundary[1], $this->LE);
- }
- else
- {
- $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- }
- break;
- case "alt":
- $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- break;
- }
-
- if($this->Mailer != "mail")
- $result .= $this->LE.$this->LE;
-
- return $result;
- }
-
- /**
- * Assembles the message body. Returns an empty string on failure.
- * @access private
- * @return string
- */
- function CreateBody() {
- $result = "";
-
- $this->SetWordWrap();
-
- switch($this->message_type)
- {
- case "alt":
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/plain", "");
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/html", "");
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[1]);
- break;
- case "plain":
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- break;
- case "attachments":
- $result .= $this->GetBoundary($this->boundary[1], "", "", "");
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE;
-
- $result .= $this->AttachAll();
- break;
- case "alt_attachments":
- $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
- $result .= sprintf("Content-Type: %s;%s" .
- "\tboundary=\"%s\"%s",
- "multipart/alternative", $this->LE,
- $this->boundary[2], $this->LE.$this->LE);
-
- // Create text body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/plain", "") . $this->LE;
-
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- // Create the HTML body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/html", "") . $this->LE;
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[2]);
-
- $result .= $this->AttachAll();
- break;
- }
- if($this->IsError())
- $result = "";
-
- return $result;
- }
-
- /**
- * Returns the start of a message boundary.
- * @access private
- */
- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
- $result = "";
- if($charSet == "") { $charSet = $this->CharSet; }
- if($contentType == "") { $contentType = $this->ContentType; }
- if($encoding == "") { $encoding = $this->Encoding; }
-
- $result .= $this->TextLine("--" . $boundary);
- $result .= sprintf("Content-Type: %s; charset = \"%s\"",
- $contentType, $charSet);
- $result .= $this->LE;
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
- $result .= $this->LE;
-
- return $result;
- }
-
- /**
- * Returns the end of a message boundary.
- * @access private
- */
- function EndBoundary($boundary) {
- return $this->LE . "--" . $boundary . "--" . $this->LE;
- }
-
- /**
- * Sets the message type.
- * @access private
- * @return void
- */
- function SetMessageType() {
- if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
- $this->message_type = "plain";
- else
- {
- if(count($this->attachment) > 0)
- $this->message_type = "attachments";
- if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
- $this->message_type = "alt";
- if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
- $this->message_type = "alt_attachments";
- }
- }
-
- /**
- * Returns a formatted header line.
- * @access private
- * @return string
- */
- function HeaderLine($name, $value) {
- return $name . ": " . $value . $this->LE;
- }
-
- /**
- * Returns a formatted mail line.
- * @access private
- * @return string
- */
- function TextLine($value) {
- return $value . $this->LE;
- }
-
- /////////////////////////////////////////////////
- // ATTACHMENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds an attachment from a path on the vtiger_filesystem.
- * Returns false if the file could not be found
- * or accessed.
- * @param string $path Path to the attachment.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddAttachment($path, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
-
- return true;
- }
-
- /**
- * Attaches all fs, string, and binary vtiger_attachments to the message.
- * Returns an empty string on failure.
- * @access private
- * @return string
- */
- function AttachAll() {
- // Return text of body
- $mime = array();
-
- // Add all vtiger_attachments
- for($i = 0; $i < count($this->attachment); $i++)
- {
- // Check for string attachment
- $bString = $this->attachment[$i][5];
- if ($bString)
- $string = $this->attachment[$i][0];
- else
- $path = $this->attachment[$i][0];
-
- $filename = $this->attachment[$i][1];
- $name = $this->attachment[$i][2];
- $encoding = $this->attachment[$i][3];
- $type = $this->attachment[$i][4];
- $disposition = $this->attachment[$i][6];
- $cid = $this->attachment[$i][7];
-
- $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
-
- if($disposition == "inline")
- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
-
- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
- $disposition, $name, $this->LE.$this->LE);
-
- // Encode as string attachment
- if($bString)
- {
- $mime[] = $this->EncodeString($string, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- else
- {
- $mime[] = $this->EncodeFile($path, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- }
-
- $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
-
- return join("", $mime);
- }
-
- /**
- * Encodes attachment in requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeFile ($path, $encoding = "base64") {
- if(!@$fd = fopen($path, "rb"))
- {
- $this->SetError($this->Lang("file_open") . $path);
- return "";
- }
- $magic_quotes = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
- $file_buffer = fread($fd, filesize($path));
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
- fclose($fd);
- set_magic_quotes_runtime($magic_quotes);
-
- return $file_buffer;
- }
-
- /**
- * Encodes string to requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeString ($str, $encoding = "base64") {
- $encoded = "";
- switch(strtolower($encoding)) {
- case "base64":
- // chunk_split is found in PHP >= 3.0.6
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
- break;
- case "7bit":
- case "8bit":
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
- break;
- case "binary":
- $encoded = $str;
- break;
- case "quoted-printable":
- $encoded = $this->EncodeQP($str);
- break;
- default:
- $this->SetError($this->Lang("encoding") . $encoding);
- break;
- }
- return $encoded;
- }
-
- /**
- * Encode a header string to best of Q, B, quoted or none.
- * @access private
- * @return string
- */
- function EncodeHeader ($str, $position = 'text') {
- $x = 0;
-
- switch (strtolower($position)) {
- case 'phrase':
- if (!preg_match('/[\200-\377]/', $str)) {
- // Can't use addslashes as we don't know what value has magic_quotes_sybase.
- $encoded = addcslashes($str, "\0..\37\177\\\"");
-
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
- return ($encoded);
- else
- return ("\"$encoded\"");
- }
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
- break;
- case 'comment':
- $x = preg_match_all('/[()"]/', $str, $matches);
- // Fall-through
- case 'text':
- default:
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
- break;
- }
-
- if ($x == 0)
- return ($str);
-
- $maxlen = 75 - 7 - strlen($this->CharSet);
- // Try to select the encoding which should produce the shortest output
- if (strlen($str)/3 < $x) {
- $encoding = 'B';
- $encoded = base64_encode($str);
- $maxlen -= $maxlen % 4;
- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
- } else {
- $encoding = 'Q';
- $encoded = $this->EncodeQ($str, $position);
- $encoded = $this->WrapText($encoded, $maxlen, true);
- $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
- }
-
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
-
- return $encoded;
- }
-
- /**
- * Encode string to quoted-printable.
- * @access private
- * @return string
- */
- function EncodeQP ($str) {
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
-
- // Replace every high ascii, control and = characters
- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- // Replace every spaces and vtiger_tabs when it's the last character on a line
- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
-
- // Maximum line length of 76 characters before CRLF (74 + space + '=')
- $encoded = $this->WrapText($encoded, 74, true);
-
- return $encoded;
- }
-
- /**
- * Encode string to q encoding.
- * @access private
- * @return string
- */
- function EncodeQ ($str, $position = "text") {
- // There should not be any EOL in the string
- $encoded = preg_replace("[\r\n]", "", $str);
-
- switch (strtolower($position)) {
- case "phrase":
- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- case "comment":
- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- case "text":
- default:
- // Replace every high ascii, control =, ? and _ characters
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- }
-
- // Replace every spaces to _ (more readable than =20)
- $encoded = str_replace(" ", "_", $encoded);
-
- return $encoded;
- }
-
- /**
- * Adds a string or binary attachment (non-filesystem) to the list.
- * This method can be used to attach ascii or binary data,
- * such as a BLOB record from a database.
- * @param string $string String attachment data.
- * @param string $filename Name of the attachment.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return void
- */
- function AddStringAttachment($string, $filename, $encoding = "base64",
- $type = "application/octet-stream") {
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $string;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $filename;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = true; // isString
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
- }
-
- /**
- * Adds an embedded attachment. This can include images, sounds, and
- * just about any other document. Make sure to set the $type to an
- * image type. For JPEG images use "image/jpeg" and for GIF images
- * use "image/gif".
- * @param string $path Path to the attachment.
- * @param string $cid Content ID of the attachment. Use this to identify
- * the Id for accessing the image in an HTML form.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
-
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "inline";
- $this->attachment[$cur][7] = $cid;
-
- return true;
- }
-
- /**
- * Returns true if an inline attachment is present.
- * @access private
- * @return bool
- */
- function InlineImageExists() {
- $result = false;
- for($i = 0; $i < count($this->attachment); $i++)
- {
- if($this->attachment[$i][6] == "inline")
- {
- $result = true;
- break;
- }
- }
-
- return $result;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE RESET METHODS
- /////////////////////////////////////////////////
-
- /**
- * Clears all recipients assigned in the TO array. Returns void.
- * @return void
- */
- function ClearAddresses() {
- $this->to = array();
- }
-
- /**
- * Clears all recipients assigned in the CC array. Returns void.
- * @return void
- */
- function ClearCCs() {
- $this->cc = array();
- }
-
- /**
- * Clears all recipients assigned in the BCC array. Returns void.
- * @return void
- */
- function ClearBCCs() {
- $this->bcc = array();
- }
-
- /**
- * Clears all recipients assigned in the ReplyTo array. Returns void.
- * @return void
- */
- function ClearReplyTos() {
- $this->ReplyTo = array();
- }
-
- /**
- * Clears all recipients assigned in the TO, CC and BCC
- * array. Returns void.
- * @return void
- */
- function ClearAllRecipients() {
- $this->to = array();
- $this->cc = array();
- $this->bcc = array();
- }
-
- /**
- * Clears all previously set vtiger_filesystem, string, and binary
- * vtiger_attachments. Returns void.
- * @return void
- */
- function ClearAttachments() {
- $this->attachment = array();
- }
-
- /**
- * Clears all custom vtiger_headers. Returns void.
- * @return void
- */
- function ClearCustomHeaders() {
- $this->CustomHeader = array();
- }
-
-
- /////////////////////////////////////////////////
- // MISCELLANEOUS METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds the error message to the error container.
- * Returns void.
- * @access private
- * @return void
- */
- function SetError($msg) {
- $this->error_count++;
- $this->ErrorInfo = $msg;
- }
-
- /**
- * Returns the proper RFC 822 formatted date.
- * @access private
- * @return string
- */
- function RFCDate() {
- $tz = date("Z");
- $tzs = ($tz < 0) ? "-" : "+";
- $tz = abs($tz);
- $tz = ($tz/3600)*100 + ($tz%3600)/60;
- $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
-
- return $result;
- }
-
- /**
- * Returns the appropriate server variable. Should work with both
- * PHP 4.1.0+ as well as older versions. Returns an empty string
- * if nothing is found.
- * @access private
- * @return mixed
- */
- function ServerVar($varName) {
- global $HTTP_SERVER_VARS;
- global $HTTP_ENV_VARS;
-
- if(!isset($_SERVER))
- {
- $_SERVER = $HTTP_SERVER_VARS;
- if(!isset($_SERVER["REMOTE_ADDR"]))
- $_SERVER = $HTTP_ENV_VARS; // must be Apache
- }
-
- if(isset($_SERVER[$varName]))
- return $_SERVER[$varName];
- else
- return "";
- }
-
- /**
- * Returns the server hostname or 'localhost.localdomain' if unknown.
- * @access private
- * @return string
- */
- function ServerHostname() {
- if ($this->Hostname != "")
- $result = $this->Hostname;
- elseif ($this->ServerVar('SERVER_NAME') != "")
- $result = $this->ServerVar('SERVER_NAME');
- else
- $result = "localhost.localdomain";
-
- return $result;
- }
-
- /**
- * Returns a message in the appropriate language.
- * @access private
- * @return string
- */
- function Lang($key) {
- require_once('config.inc.php');
- global $default_language;
- if(count($this->language) < 1)
- $this->SetLanguage($default_language);
-
- if(isset($this->language[$key]))
- return $this->language[$key];
- else
- return "Language string failed to load: " . $key;
- }
-
- /**
- * Returns true if an error occurred.
- * @return bool
- */
- function IsError() {
- return ($this->error_count > 0);
- }
-
- /**
- * Changes every end of line from CR or LF to CRLF.
- * @access private
- * @return string
- */
- function FixEOL($str) {
- $str = str_replace("\r\n", "\n", $str);
- $str = str_replace("\r", "\n", $str);
- $str = str_replace("\n", $this->LE, $str);
- return $str;
- }
-
- /**
- * Adds a custom header.
- * @return void
- */
- function AddCustomHeader($custom_header) {
- $this->CustomHeader[] = explode(":", $custom_header, 2);
- }
-}
-
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/class.smtp.php b/oss/vtiger/trunk/modules/Emails/class.smtp.php
deleted file mode 100644
index abba3404..00000000
--- a/oss/vtiger/trunk/modules/Emails/class.smtp.php
+++ /dev/null
@@ -1,1050 +0,0 @@
-smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
-
- $this->do_debug = 0;
- }
-
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
-
- /**
- * Connect to the server specified on the port specified.
- * If the port is not specified use the default SMTP_PORT.
- * If tval is specified then a connection will try and be
- * established with the server for that number of seconds.
- * If tval is not specified the default is 30 seconds to
- * try on the connection.
- *
- * SMTP CODE SUCCESS: 220
- * SMTP CODE FAILURE: 421
- * @access public
- * @return bool
- */
- function Connect($host,$port=0,$tval=30) {
- # set the error val to null so there is no confusion
- $this->error = null;
-
- # make sure we are __not__ connected
- if($this->connected()) {
- # ok we are connected! what should we do?
- # for now we will just give an error saying we
- # are already connected
- $this->error =
- array("error" => "Already connected to a server");
- return false;
- }
-
- if(empty($port)) {
- $port = $this->SMTP_PORT;
- }
-
- #connect to the smtp server
- if(!@$this->smtp_conn = fsockopen($host, # the host of the server
- $port, # the port to use
- $errno, # error number if any
- $errstr, # error message if any
- $tval)) # give up after ? secs
- {
- //echo 'Could Not connect to Mail Server
';
- return false;
- }
-
- # verify we connected properly
- if(empty($this->smtp_conn)) {
- $this->error = array("error" => "Failed to connect to server",
- "errno" => $errno,
- "errstr" => $errstr);
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
- }
- return false;
- }
-
- # sometimes the SMTP server takes a little longer to respond
- # so we will give it a longer timeout for the first read
- // Windows still does not have support for this timeout function
- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
-
- # get any vtiger_announcement stuff
- $announce = $this->get_lines();
-
- # set the timeout of any socket functions at 1/10 of a second
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
- }
-
- return true;
- }
-
- /**
- * Performs SMTP authentication. Must be run after running the
- * Hello() method. Returns true if successfully authenticated.
- * @access public
- * @return bool
- */
- function Authenticate($username, $password) {
- // Start authentication
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "AUTH not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded username
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "Username not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded password
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 235) {
- $this->error =
- array("error" => "Password not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns true if connected to a server otherwise false
- * @access private
- * @return bool
- */
- function Connected() {
- if(!empty($this->smtp_conn)) {
- $sock_status = socket_get_status($this->smtp_conn);
- if($sock_status["eof"]) {
- # hmm this is an odd situation... the socket is
- # valid but we aren't connected anymore
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE:" . $this->CRLF .
- "EOF caught while checking if connected";
- }
- $this->Close();
- return false;
- }
- return true; # everything looks good
- }
- return false;
- }
-
- /**
- * Closes the socket and cleans up the state of the class.
- * It is not considered good to use this function without
- * first trying to use QUIT.
- * @access public
- * @return void
- */
- function Close() {
- $this->error = null; # so there is no confusion
- $this->helo_rply = null;
- if(!empty($this->smtp_conn)) {
- # close the connection and cleanup
- fclose($this->smtp_conn);
- $this->smtp_conn = 0;
- }
- }
-
-
- /***************************************************************
- * SMTP COMMANDS *
- *************************************************************/
-
- /**
- * Issues a data command and sends the msg_data to the server
- * finializing the mail transaction. $msg_data is the message
- * that is to be send with the vtiger_headers. Each header needs to be
- * on a single line followed by a with the message vtiger_headers
- * and the message body being seperated by and additional .
- *
- * Implements rfc 821: DATA
- *
- * SMTP CODE INTERMEDIATE: 354
- * [data]
- * .
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 552,554,451,452
- * SMTP CODE FAILURE: 451,554
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Data($msg_data) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Data() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 354) {
- $this->error =
- array("error" => "DATA command not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # the server is ready to accept data!
- # according to rfc 821 we should not send more than 1000
- # including the CRLF
- # characters on a single line so we will break the data up
- # into lines by \r and/or \n then if needed we will break
- # each of those into smaller lines to fit within the limit.
- # in addition we will be looking for lines that start with
- # a period '.' and append and additional period '.' to that
- # line. NOTE: this does not count towards are limit.
-
- # normalize the line breaks so we know the explode works
- $msg_data = str_replace("\r\n","\n",$msg_data);
- $msg_data = str_replace("\r","\n",$msg_data);
- $lines = explode("\n",$msg_data);
-
- # we need to find a good way to determine is vtiger_headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg vtiger_headers
- # and if the first vtiger_field of the first line (':' sperated)
- # does not contain a space then it _should_ be a header
- # and we can process all lines before a blank "" line as
- # vtiger_headers.
- $field = substr($lines[0],0,strpos($lines[0],":"));
- $in_headers = false;
- if(!empty($field) && !strstr($field," ")) {
- $in_headers = true;
- }
-
- $max_line_length = 998; # used below; set here for ease in change
-
- while(list(,$line) = @each($lines)) {
- $lines_out = null;
- if($line == "" && $in_headers) {
- $in_headers = false;
- }
- # ok we need to break this line up into several
- # smaller lines
- while(strlen($line) > $max_line_length) {
- $pos = strrpos(substr($line,0,$max_line_length)," ");
-
- # Patch to fix DOS attack
- if(!$pos) {
- $pos = $max_line_length - 1;
- }
-
- $lines_out[] = substr($line,0,$pos);
- $line = substr($line,$pos + 1);
- # if we are processing vtiger_headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg vtiger_headers
- if($in_headers) {
- $line = "\t" . $line;
- }
- }
- $lines_out[] = $line;
-
- # now send the lines to the server
- while(list(,$line_out) = @each($lines_out)) {
- if(strlen($line_out) > 0)
- {
- if(substr($line_out, 0, 1) == ".") {
- $line_out = "." . $line_out;
- }
- }
- fputs($this->smtp_conn,$line_out . $this->CRLF);
- }
- }
-
- # ok all the message data has been sent so lets get this
- # over with aleady
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "DATA not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Expand takes the name and asks the server to list all the
- * people who are members of the _list_. Expand will return
- * back and array of the result or false if an error occurs.
- * Each value in the array returned has the format of:
- * [ ]
- * The definition of is defined in rfc 821
- *
- * Implements rfc 821: EXPN
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 550
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string array
- */
- function Expand($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Expand() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "EXPN not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # parse the reply and place in our array to return to user
- $entries = explode($this->CRLF,$rply);
- while(list(,$l) = @each($entries)) {
- $list[] = substr($l,4);
- }
-
- return $list;
- }
-
- /**
- * Sends the HELO command to the smtp server.
- * This makes sure that we and the server are in
- * the same known state.
- *
- * Implements from rfc 821: HELO
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 501, 504, 421
- * @access public
- * @return bool
- */
- function Hello($host="") {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Hello() without being connected");
- return false;
- }
-
- # if a hostname for the HELO wasn't specified determine
- # a suitable one to send
- if(empty($host)) {
- # we need to determine some sort of appopiate default
- # to send to the server
- $host = "localhost";
- }
-
- // Send extended hello first (RFC 2821)
- if(!$this->SendHello("EHLO", $host))
- {
- if(!$this->SendHello("HELO", $host))
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends a HELO/EHLO command.
- * @access private
- * @return bool
- */
- function SendHello($hello, $host) {
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => $hello . " not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- $this->helo_rply = $rply;
-
- return true;
- }
-
- /**
- * Gets help information on the keyword specified. If the keyword
- * is not specified then returns generic help, ussually contianing
- * A list of keywords that help is available on. This function
- * returns the results back to the user. It is up to the user to
- * handle the returned data. If an error occurs then false is
- * returned with $this->error set appropiately.
- *
- * Implements rfc 821: HELP [ ]
- *
- * SMTP CODE SUCCESS: 211,214
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string
- */
- function Help($keyword="") {
- $this->error = null; # to avoid confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Help() without being connected");
- return false;
- }
-
- $extra = "";
- if(!empty($keyword)) {
- $extra = " " . $keyword;
- }
-
- fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 211 && $code != 214) {
- $this->error =
- array("error" => "HELP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return $rply;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command.
- *
- * Implements rfc 821: MAIL FROM:
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,421
- * @access public
- * @return bool
- */
- function Mail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Mail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "MAIL not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the command NOOP to the SMTP server.
- *
- * Implements from rfc 821: NOOP
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 421
- * @access public
- * @return bool
- */
- function Noop() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Noop() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"NOOP" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "NOOP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the quit command to the server and then closes the socket
- * if there is no error or the $close_on_error argument is true.
- *
- * Implements from rfc 821: QUIT
- *
- * SMTP CODE SUCCESS: 221
- * SMTP CODE ERROR : 500
- * @access public
- * @return bool
- */
- function Quit($close_on_error=true) {
- $this->error = null; # so there is no confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Quit() without being connected");
- return false;
- }
-
- # send the quit command to the server
- fputs($this->smtp_conn,"quit" . $this->CRLF);
-
- # get any good-bye messages
- $byemsg = $this->get_lines();
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
- }
-
- $rval = true;
- $e = null;
-
- $code = substr($byemsg,0,3);
- if($code != 221) {
- # use e as a tmp var cause Close will overwrite $this->error
- $e = array("error" => "SMTP server rejected quit command",
- "smtp_code" => $code,
- "smtp_rply" => substr($byemsg,4));
- $rval = false;
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
- $byemsg . $this->CRLF;
- }
- }
-
- if(empty($e) || $close_on_error) {
- $this->Close();
- }
-
- return $rval;
- }
-
- /**
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
- * Returns true if the recipient was accepted false if it was rejected.
- *
- * Implements from rfc 821: RCPT TO:
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Recipient($to) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Recipient() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "RCPT not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the RSET command to abort and transaction that is
- * currently in progress. Returns true if successful false
- * otherwise.
- *
- * Implements rfc 821: RSET
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500,501,504,421
- * @access public
- * @return bool
- */
- function Reset() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Reset() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "RSET failed",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the vtiger_users terminal if they are logged
- * in.
- *
- * Implements rfc 821: SEND FROM:
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function Send($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Send() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SEND not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the vtiger_users terminal if they are logged
- * in and send them an email.
- *
- * Implements rfc 821: SAML FROM:
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendAndMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendAndMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SAML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the vtiger_users terminal if they are logged
- * in or mail it to them if they are not.
- *
- * Implements rfc 821: SOML FROM:
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendOrMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendOrMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SOML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * This is an optional command for SMTP that this class does not
- * support. This method is here to make the RFC821 Definition
- * complete for this class and __may__ be implimented in the future
- *
- * Implements from rfc 821: TURN
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 502
- * SMTP CODE ERROR : 500, 503
- * @access public
- * @return bool
- */
- function Turn() {
- $this->error = array("error" => "This method, TURN, of the SMTP ".
- "is not implemented");
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
- }
- return false;
- }
-
- /**
- * Verifies that the name is recognized by the server.
- * Returns false if the name could not be verified otherwise
- * the response from the server is returned.
- *
- * Implements rfc 821: VRFY
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,553
- * SMTP CODE ERROR : 500,501,502,421
- * @access public
- * @return int
- */
- function Verify($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Verify() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "VRFY failed on name '$name'",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return $rply;
- }
-
- /*******************************************************************
- * INTERNAL FUNCTIONS *
- ******************************************************************/
-
- /**
- * Read in as many lines as possible
- * either before eof or socket timeout occurs on the operation.
- * With SMTP we can tell if we have more lines to read if the
- * 4th character is '-' symbol. If it is a space then we don't
- * need to read anything else.
- * @access private
- * @return string
- */
- function get_lines() {
- $data = "";
- while($str = fgets($this->smtp_conn,515)) {
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data was \"$data\"" .
- $this->CRLF;
- echo "SMTP -> get_lines(): \$str is \"$str\"" .
- $this->CRLF;
- }
- $data .= $str;
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
- }
- # if the 4th character is a space then we are done reading
- # so just break the loop
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
- }
-
-}
-
-
- ?>
diff --git a/oss/vtiger/trunk/modules/Emails/gotodownload.php b/oss/vtiger/trunk/modules/Emails/gotodownload.php
deleted file mode 100644
index e6340089..00000000
--- a/oss/vtiger/trunk/modules/Emails/gotodownload.php
+++ /dev/null
@@ -1,82 +0,0 @@
-parameters[0]->value;
- $strFileType = strrev(substr(strrev($strFileName),0,4));
- $fileContent = imap_fetchbody($mbox,$msgno,$file+2);
-}
-
-/** Function to download the File
- * @param string $strFileType - File Type
- * @param string $strFileName - File Name
- * @param string $fileContents- File contents
-**/
-function downloadFile($strFileType,$strFileName,$fileContent)
-{
- $ContentType = "application/octet-stream";
-
- if ($strFileType == ".asf")
- $ContentType = "video/x-ms-asf";
- if ($strFileType == ".avi")
- $ContentType = "video/avi";
- if ($strFileType == ".doc")
- $ContentType = "application/msword";
- if ($strFileType == ".zip")
- $ContentType = "application/zip";
- if ($strFileType == ".xls")
- $ContentType = "application/vnd.ms-excel";
- if ($strFileType == ".gif")
- $ContentType = "image/gif";
- if ($strFileType == ".jpg" || $strFileType == "jpeg")
- $ContentType = "image/jpeg";
- if ($strFileType == ".wav")
- $ContentType = "audio/wav";
- if ($strFileType == ".mp3")
- $ContentType = "audio/mpeg3";
- if ($strFileType == ".mpg" || $strFileType == "mpeg")
- $ContentType = "video/mpeg";
- if ($strFileType == ".rtf")
- $ContentType = "application/rtf";
- if ($strFileType == ".htm" || $strFileType == "html")
- $ContentType = "text/html";
- if ($strFileType == ".xml")
- $ContentType = "text/xml";
- if ($strFileType == ".xsl")
- $ContentType = "text/xsl";
- if ($strFileType == ".css")
- $ContentType = "text/css";
- if ($strFileType == ".php")
- $ContentType = "text/php";
- if ($strFileType == ".asp")
- $ContentType = "text/asp";
- if ($strFileType == ".pdf")
- $ContentType = "application/pdf";
-
- header ("Content-Type: $ContentType");
- header("Cache-Control: private");
- header("Content-Description: PHP Generated Data");
- header ("Content-Disposition: attachment; filename=$strFileName");
- echo imap_base64($fileContent);
- #echo base64_decode($fileContent);
-}
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/index.php b/oss/vtiger/trunk/modules/Emails/index.php
deleted file mode 100644
index 0c3a5ef8..00000000
--- a/oss/vtiger/trunk/modules/Emails/index.php
+++ /dev/null
@@ -1,31 +0,0 @@
-'.$mod_strings['LBL_MAIL_CONNECT_ERROR_INFO'].'
';
-}
-
-include ('modules/Emails/ListView.php');
-
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/language/en_us.lang.php b/oss/vtiger/trunk/modules/Emails/language/en_us.lang.php
deleted file mode 100644
index 4b84eafb..00000000
--- a/oss/vtiger/trunk/modules/Emails/language/en_us.lang.php
+++ /dev/null
@@ -1,183 +0,0 @@
-'General Information',
-
-'LBL_MODULE_NAME'=>'Email',
-'LBL_MODULE_TITLE'=>'Email: Home',
-'LBL_SEARCH_FORM_TITLE'=>'Email Search',
-'LBL_LIST_FORM_TITLE'=>'Email List',
-'LBL_NEW_FORM_TITLE'=>'Track Email',
-
-'LBL_LIST_SUBJECT'=>'Subject',
-'LBL_LIST_CONTACT'=>'Contact',
-'LBL_LIST_RELATED_TO'=>'Related to',
-'LBL_LIST_DATE'=>'Date Sent',
-'LBL_LIST_TIME'=>'Time Sent',
-
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
-'LBL_DATE_SENT'=>'Date Sent:',
-'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
-'LBL_DATE'=>'Date Sent:',
-'LBL_TIME'=>'Time Sent:',
-'LBL_SUBJECT'=>'Subject:',
-'LBL_BODY'=>'Body:',
-'LBL_CONTACT_NAME'=>' Contact Name: ',
-'LBL_EMAIL'=>'Email:',
-'LBL_DETAILVIEW_EMAIL'=>'E-Mail',
-'LBL_COLON'=>':',
-'LBL_CHK_MAIL'=>'Check Mail',
-'LBL_COMPOSE'=>'Compose',
-//Single change for 5.0.3
-'LBL_SETTINGS'=>'Incoming Mail Server Settings',
-'LBL_EMAIL_FOLDERS'=>'Email Folders',
-'LBL_INBOX'=>'Inbox',
-'LBL_SENT_MAILS'=>'Sent Mails',
-'LBL_TRASH'=>'Trash',
-'LBL_JUNK_MAILS'=>'Junk Mails',
-'LBL_TO_LEADS'=>'To Leads',
-'LBL_TO_CONTACTS'=>'To Contacts',
-'LBL_TO_ACCOUNTS'=>'To Accounts',
-'LBL_MY_MAILS'=>'My Mails',
-'LBL_QUAL_CONTACT'=>'Qualified Mails (As Contacts)',
-'LBL_MAILS'=>'Mails',
-'LBL_QUALIFY_BUTTON'=>'Qualify',
-'LBL_REPLY_BUTTON'=>'Reply',
-'LBL_FORWARD_BUTTON'=>'Forward',
-'LBL_DOWNLOAD_ATTCH_BUTTON'=>'Download Attachments',
-'LBL_FROM'=>'From :',
-'LBL_CC'=>'Cc :',
-'LBL_BCC'=>'Bcc :',
-
-'NTC_REMOVE_INVITEE'=>'Are you sure you want to remove this recipient from the email?',
-'LBL_INVITEE'=>'Recipients',
-
-// Added Fields
-// Contacts-SubPanelViewContactsAndUsers.php
-'LBL_BULK_MAILS'=>'Bulk Mails',
-'LBL_ATTACHMENT'=>'Attachment',
-'LBL_UPLOAD'=>'Upload',
-'LBL_FILE_NAME'=>'File Name',
-'LBL_SEND'=>'Send',
-
-'LBL_EMAIL_TEMPLATES'=>'Email Templates',
-'LBL_TEMPLATE_NAME'=>'Template Name',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_EMAIL_TEMPLATES_LIST'=>'Email Templates List',
-'LBL_EMAIL_INFORMATION'=>'Email Information',
-
-
-
-
-//for v4 release added
-'LBL_NEW_LEAD'=>'New Lead',
-'LBL_LEAD_TITLE'=>'Leads',
-
-'LBL_NEW_PRODUCT'=>'New Product',
-'LBL_PRODUCT_TITLE'=>'Products',
-'LBL_NEW_CONTACT'=>'New Contact',
-'LBL_CONTACT_TITLE'=>'Contacts',
-'LBL_NEW_ACCOUNT'=>'New Account',
-'LBL_ACCOUNT_TITLE'=>'Accounts',
-
-// Added vtiger_fields after vtiger4 - Beta
-'LBL_USER_TITLE'=>'Users',
-'LBL_NEW_USER'=>'New User',
-
-// Added for 4 GA
-'LBL_TOOL_FORM_TITLE'=>'Email Tools',
-//Added for 4GA
-'Date & Time Sent'=>'Date & Time Sent',
-'Sales Enity Module'=>'Sales Enity Module',
-'Related To'=>'Related To',
-'Assigned To'=>'Assigned To',
-'Subject'=>'Subject',
-'Attachment'=>'Attachment',
-'Description'=>'Description',
-'Time Start'=>'Time Start',
-'Created Time'=>'Created Time',
-'Modified Time'=>'Modified Time',
-
-'MESSAGE_CHECK_MAIL_SERVER_NAME'=>'Please Check the Mail Server Name...',
-'MESSAGE_CHECK_MAIL_ID'=>'Please Check the Email Id of "Assigned To" User...',
-'MESSAGE_MAIL_HAS_SENT_TO_USERS'=>'Mail has been sent to the following User(s) :',
-'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS'=>'Mail has been sent to the following Contact(s) :',
-'MESSAGE_MAIL_ID_IS_INCORRECT'=>'Mail Id is incorrect. Please Check this Mail Id...',
-'MESSAGE_ADD_USER_OR_CONTACT'=>'Please Add any User(s) or Contact(s)...',
-'MESSAGE_MAIL_SENT_SUCCESSFULLY'=>' Mail(s) sent successfully!',
-
-// Added for web mail post 4.0.1 release
-'LBL_FETCH_WEBMAIL'=>'Fetch Web Mail',
-//Added for 4.2 Release -- CustomView
-'LBL_ALL'=>'All',
-'MESSAGE_CONTACT_NOT_WANT_MAIL'=>'This Contact does not want to receive mails.',
-'LBL_WEBMAILS_TITLE'=>'WebMails',
-'LBL_EMAILS_TITLE'=>'Email',
-'LBL_MAIL_CONNECT_ERROR_INFO'=>'Error connecting mail server!
Check in My Accounts->List Mail Server -> List Mail Account',
-'LBL_ALLMAILS'=>'All Mails',
-'LBL_TO_USERS'=>'To Users',
-'LBL_TO'=>'To:',
-'LBL_IN_SUBJECT'=>'in Subject',
-'LBL_IN_SENDER'=>'in Sender',
-'LBL_IN_SUBJECT_OR_SENDER'=>'in Subject or Sender',
-'SELECT_EMAIL'=>'Select Email IDs',
-'Sender'=>'Sender',
-'LBL_CONFIGURE_MAIL_SETTINGS'=>'Your Incoming Mail Server is not configured',
-'LBL_MAILSELECT_INFO1'=>'The following Email ID types are associated to the selected',
-'LBL_MAILSELECT_INFO2'=>'Select the Email ID types to which,the email should be sent',
-'LBL_MULTIPLE'=>'Multiple',
-'LBL_COMPOSE_EMAIL'=>'Compose E-Mail',
-'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail Client',
-
-//Added for 5.0.3
-'TITLE_VTIGERCRM_MAIL'=>'vtigerCRM Mail',
-'TITLE_COMPOSE_MAIL'=>'Compose Mail',
-
-'MESSAGE_MAIL_COULD_NOT_BE_SEND'=>'Mail could not be sent to the assigned to user.',
-'MESSAGE_PLEASE_CHECK_ASSIGNED_USER_EMAILID'=>'Please check the assigned to user email id...',
-'MESSAGE_PLEASE_CHECK_THE_FROM_MAILID'=>'Please check the from email id',
-'MESSAGE_MAIL_COULD_NOT_BE_SEND_TO_THIS_EMAILID'=>'Mail could not be sent to this email id',
-'PLEASE_CHECK_THIS_EMAILID'=>'Please check this mail id...',
-'LBL_CC_EMAIL_ERROR'=>'Your cc mailid is not proper',
-'LBL_BCC_EMAIL_ERROR'=>'Your bcc mailid is not proper',
-'LBL_NO_RCPTS_EMAIL_ERROR'=>'No recepients specified',
-'LBL_CONF_MAILSERVER_ERROR'=>'Please configure your outgoing mailserver under Settings ---> Outgoing Server link',
-'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail Client',
-'LBL_MAILSELECT_INFO3'=>'You don\'t have permission to view email id(s) of the selected Record(s).',
-//Added for script alerts
-'FEATURE_AVAILABLE_INFO' => 'This feature is currently only available for Microsoft Internet Explorer 5.5+ users\n\nWait f
-or an update!',
-'DOWNLOAD_CONFIRAMATION' => 'Do you want to download the file ?',
-'LBL_PLEASE_ATTACH' => 'Please give a valid file to attach and try again!',
-'LBL_KINDLY_UPLOAD' => 'Please configure upload_tmp_dir variable in php.ini file.',
-'LBL_EXCEED_MAX' => 'Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than ',
-'LBL_BYTES' => ' bytes',
-'LBL_CHECK_USER_MAILID' => 'Please check the current user mailid.It should be a valid mailid to send Emails',
-
-// Added/Updated for vtiger CRM 5.0.4
-'Activity Type'=>'Activity Type',
-'LBL_MAILSELECT_INFO'=>'has the following Email IDs associated.Please Select the Email IDs to which,the mail should be sent',
-'LBL_NO_RECORDS' => 'No Records Found',
-'LBL_PRINT_EMAIL'=> 'Print',
-
-);
-
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-en_us.php b/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-en_us.php
deleted file mode 100644
index 7b09c424..00000000
--- a/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-en_us.php
+++ /dev/null
@@ -1,31 +0,0 @@
-.';
-$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
-$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
-$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-zh_cn.php b/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-zh_cn.php
deleted file mode 100644
index 7b09c424..00000000
--- a/oss/vtiger/trunk/modules/Emails/language/phpmailer.lang-zh_cn.php
+++ /dev/null
@@ -1,31 +0,0 @@
-.';
-$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
-$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
-$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Emails/language/zh_cn.lang.php
deleted file mode 100644
index 6fa50c4b..00000000
--- a/oss/vtiger/trunk/modules/Emails/language/zh_cn.lang.php
+++ /dev/null
@@ -1,184 +0,0 @@
- '一般信息',
-
- 'LBL_MODULE_NAME' => '邮件',
- 'LBL_MODULE_TITLE' => '邮件: 首页',
- 'LBL_SEARCH_FORM_TITLE' => '搜寻邮件',
- 'LBL_LIST_FORM_TITLE' => '邮件列表',
- 'LBL_NEW_FORM_TITLE' => '追踪邮件',
-
- 'LBL_LIST_SUBJECT' => '标题',
- 'LBL_LIST_CONTACT' => '联系人',
- 'LBL_LIST_RELATED_TO' => '相关人事',
- 'LBL_LIST_DATE' => '寄出日期',
- 'LBL_LIST_TIME' => '寄出时间',
-
- 'ERR_DELETE_RECORD' => '必须有记录编号才能删除该笔账号.',
- 'LBL_DATE_SENT' => '寄出日期:',
- 'LBL_DATE_AND_TIME' => '寄出日期 & 时间:',
- 'LBL_DATE' => '寄出日期:',
- 'LBL_TIME' => '寄出时间:',
- 'LBL_SUBJECT' => '标题:',
- 'LBL_BODY' => '邮件内容:',
- 'LBL_CONTACT_NAME' => '联系人名称: ',
-'LBL_EMAIL' => '邮件:',
-'LBL_DETAILVIEW_EMAIL'=>'邮件',
-'LBL_COLON'=>':',
-'LBL_CHK_MAIL'=>'检查邮件',
-'LBL_COMPOSE'=>'新邮件',
-//Single change for 5.0.3
-'LBL_SETTINGS'=>'邮件服务器设置',
-'LBL_EMAIL_FOLDERS'=>'邮件数据夹',
-'LBL_INBOX' => '收件夹',
-'LBL_SENT_MAILS'=>'邮件备份',
-'LBL_TRASH' => '垃圾桶',
- 'LBL_JUNK_MAILS' => '广告邮件',
- 'LBL_TO_LEADS' => '转为准客户',
- 'LBL_TO_CONTACTS' => '转为联系人',
- 'LBL_TO_ACCOUNTS' => '转为客户',
- 'LBL_MY_MAILS' => '我的邮件',
- 'LBL_QUAL_CONTACT' => '已转换邮件(转为联系人)',
- 'LBL_MAILS' => '邮件',
- 'LBL_QUALIFY_BUTTON' => '转换',
- 'LBL_REPLY_BUTTON' => '回应',
- 'LBL_FORWARD_BUTTON' => '转寄',
- 'LBL_DOWNLOAD_ATTCH_BUTTON' => '下载附加档案',
- 'LBL_FROM' => '寄件人:',
- 'LBL_CC' => '副本:',
- 'LBL_BCC' => '密件副本:',
-
- 'NTC_REMOVE_INVITEE' => '您确定要移除这封来信?',
-'LBL_INVITEE'=>'接收者',
-
-// Added Fields
-// Contacts-SubPanelViewContactsAndUsers.php
- 'LBL_BULK_MAILS' => '大量寄信',
- 'LBL_ATTACHMENT' => '附件',
-'LBL_UPLOAD' => '上传',
- 'LBL_FILE_NAME' => '文件名称',
- 'LBL_SEND' => '寄出',
-
-'LBL_EMAIL_TEMPLATES' => '邮件样版',
- 'LBL_TEMPLATE_NAME' => '样版名称',
- 'LBL_DESCRIPTION' => '描述',
- 'LBL_EMAIL_TEMPLATES_LIST' => '邮件样版列表',
- 'LBL_EMAIL_INFORMATION' => '邮件信息',
-
-
-
-
-//for v4 release added
- 'LBL_NEW_LEAD' => '新增潜在客户',
- 'LBL_LEAD_TITLE' => '潜在客户',
-
- 'LBL_NEW_PRODUCT' => '新增商品',
- 'LBL_PRODUCT_TITLE' => '商品',
- 'LBL_NEW_CONTACT' => '新增联系人',
- 'LBL_CONTACT_TITLE' => '联系人',
- 'LBL_NEW_ACCOUNT' => '新增公司',
- 'LBL_ACCOUNT_TITLE' => '公司',
-
-// Added vtiger_fields after vtiger4 - Beta
-'LBL_USER_TITLE' => '使用者',
- 'LBL_NEW_USER' => '新增使用者',
-
-// Added for 4 GA
- 'LBL_TOOL_FORM_TITLE' => '邮件编辑器',
-//Added for 4GA
-'Date & Time Sent' => '寄出日期 & 时间',
- 'Sales Enity Module' => '客服模块',
-
- 'Related To' => '相关人事',
- 'Assigned To' => '负责人',
- 'Subject' => '标题',
- 'Attachment' => '附件',
- 'Description' => '描述',
- 'Time Start' => '开始时间',
- 'Created Time' => '建立时间',
- 'Modified Time' => '修改时间',
-
- 'MESSAGE_CHECK_MAIL_SERVER_NAME' => '请检查电子邮件服务器名称...',
- 'MESSAGE_CHECK_MAIL_ID' => '请检查负责人的信箱编号...',
- 'MESSAGE_MAIL_HAS_SENT_TO_USERS' => '邮件将会寄出给指定的使用者:',
- 'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS' => '邮件将会寄出给指定的联系人:',
- 'MESSAGE_MAIL_ID_IS_INCORRECT' => '邮件格式不正确. 请检查这封邮件的Id...',
- 'MESSAGE_ADD_USER_OR_CONTACT' => '请新增其它位使用者或联系人...',
- 'MESSAGE_MAIL_SENT_SUCCESSFULLY' => ' 邮件已顺利寄出!',
-
-// Added for web mail post 4.0.1 release
- 'LBL_FETCH_WEBMAIL' => '取得网页邮件',
-//Added for 4.2 Release -- CustomView
- 'LBL_ALL' => '全部',
- 'MESSAGE_CONTACT_NOT_WANT_MAIL' => '这个联系人不想要收到电子邮件',
- 'LBL_WEBMAILS_TITLE' => '网页邮件',
- 'LBL_EMAILS_TITLE' => '电子邮件',
- 'LBL_MAIL_CONNECT_ERROR_INFO' => '联机到邮件服务器时发生错误,检查我的账号=>邮件服务器列表=>邮件账号',
- 'LBL_ALLMAILS' => '所有邮件',
- 'LBL_TO_USERS' => '给使用者',
- 'LBL_TO' => '收件人:',
-'LBL_IN_SUBJECT' => '主旨',
- 'LBL_IN_SENDER' => '寄件人',
- 'LBL_IN_SUBJECT_OR_SENDER' => '主旨或寄件人',
- 'SELECT_EMAIL' => '选择邮件编号',
- 'Sender' => '寄件人',
- 'LBL_CONFIGURE_MAIL_SETTINGS' => '您的收件邮件服务器还没设定',
- 'LBL_MAILSELECT_INFO' => '有下面相关邮件编号,请选择要寄送的邮件编号',
- 'LBL_MAILSELECT_INFO1' => '下面的邮件编号与选择的项目有关',
- 'LBL_MAILSELECT_INFO2' => '选择要寄送的邮件编号类型',
- 'LBL_MULTIPLE' => '多选',
- 'LBL_COMPOSE_EMAIL' => '发送邮件',
- 'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail 客户',
-
-//Added for 5.0.3
-'TITLE_VTIGERCRM_MAIL'=>'vtigerCRM 邮件',
-'TITLE_COMPOSE_MAIL'=>'组成邮件',
-
-'MESSAGE_MAIL_COULD_NOT_BE_SEND'=>'邮件不能寄发到被分配的用户.',
-'MESSAGE_PLEASE_CHECK_ASSIGNED_USER_EMAILID'=>'请检查被分配的用户电子邮件id...',
-'MESSAGE_PLEASE_CHECK_THE_FROM_MAILID'=>'请检查电子邮件id',
-'MESSAGE_MAIL_COULD_NOT_BE_SEND_TO_THIS_EMAILID'=>'邮件不能寄发到这电子邮件id',
-'PLEASE_CHECK_THIS_EMAILID'=>'请检查这邮件id...',
-'LBL_CC_EMAIL_ERROR'=>'您的CC邮件ID不是适当的',
-'LBL_BCC_EMAIL_ERROR'=>'您的BCC邮件ID不是适当的',
-'LBL_NO_RCPTS_EMAIL_ERROR'=>'没有指定移植对象',
-'LBL_CONF_MAILSERVER_ERROR'=>'请设置您外部的邮件服务器 ---> 外出的服务器链接',
-'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail 客户',
-'LBL_MAILSELECT_INFO3'=>'您不能查看选择记录的邮件ID.',
-'LBL_NO_RECORDS' => '这个文件夹没有记录',
-//Added for script alerts
-'FEATURE_AVAILABLE_INFO' => '这个特点只支持Microsoft Internet Explorer 5.5+或更高!',
-'DOWNLOAD_CONFIRAMATION' => '您想要下载文件 ?',
-'LBL_PLEASE_ATTACH' => '请再尝试附上一个合法的文件',
-'LBL_KINDLY_UPLOAD' => '请配置 upload_tmp_dir variable in php.ini file.',
-'LBL_EXCEED_MAX' => '抱歉, 上传的文件超出最大值极限。请尝试一个小文件 ',
-'LBL_BYTES' => ' 字节',
-'LBL_CHECK_USER_MAILID' => '请检查当前用户的电邮ID是否正确',
-
-// Added/Updated for vtiger CRM 5.0.4
-'Activity Type'=>'任务类型',
-'LBL_MAILSELECT_INFO'=>'has the following Email IDs associated.Please Select the Email IDs to which,the mail should be sent',
-'LBL_NO_RECORDS' => 'No Records Found',
-'LBL_PRINT_EMAIL'=> 'Print',
-);
-
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/mail.php b/oss/vtiger/trunk/modules/Emails/mail.php
deleted file mode 100644
index 9e028af4..00000000
--- a/oss/vtiger/trunk/modules/Emails/mail.php
+++ /dev/null
@@ -1,535 +0,0 @@
-println("To id => '".$to_email."'\nSubject ==>'".$subject."'\nContents ==> '".$contents."'");
-
- //Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table)
- //$to_email = getUserEmailId('id',$assigned_user_id);
-
- //if module is HelpDesk then from_email will come based on support email id
- if($from_email == '') {
- //if from email is not defined, then use the useremailid as the from address
- $from_email = getUserEmailId('user_name',$from_name);
- }
-
- //if the newly defined from email field is set, then use this email address as the from address
- //and use the username as the reply-to address
- $query = "select * from vtiger_systems where server_type=?";
- $params = array('email');
- $result = $adb->pquery($query,$params);
- $from_email_field = $adb->query_result($result,0,'from_email_field');
- $replyToEmail = $from_email;
- if(isset($from_email_field) && $from_email_field!=''){
- //setting from _email to the defined email address in the outgoing server configuration
- $from_email = $from_email_field;
- }
-
- if($module != "Calendar")
- $contents = addSignature($contents,$from_name);
-
- $mail = new PHPMailer();
-
- setMailerProperties($mail,$subject,$contents,$from_email,$from_name,trim($to_email,","),$attachment,$emailid,$module,$logo);
- setCCAddress($mail,'cc',$cc);
- setCCAddress($mail,'bcc',$bcc);
- $mail->AddReplyTo($replyToEmail);
-
- // vtmailscanner customization: If Support Reply to is defined use it.
- global $HELPDESK_SUPPORT_EMAIL_REPLY_ID;
- if($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) {
- $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID);
- }
- // END
-
- // Fix: Return immediately if Outgoing server not configured
- if(empty($mail->Host)) {
- return 0;
- }
- // END
-
- $mail_status = MailSend($mail);
-
- if($mail_status != 1)
- {
- $mail_error = getMailError($mail,$mail_status,$mailto);
- }
- else
- {
- $mail_error = $mail_status;
- }
-
- return $mail_error;
-}
-
-/** Function to get the user Email id based on column name and column value
- * $name -- column name of the vtiger_users vtiger_table
- * $val -- column value
- */
-function getUserEmailId($name,$val)
-{
- global $adb;
- $adb->println("Inside the function getUserEmailId. --- ".$name." = '".$val."'");
- if($val != '')
- {
- //$sql = "select email1, email2, yahoo_id from vtiger_users where ".$name." = '".$val."'";
- //done to resolve the PHP5 specific behaviour
- $sql = "SELECT email1, email2, yahoo_id from vtiger_users WHERE status='Active' AND ". $adb->sql_escape_string($name)." = ?";
- $res = $adb->pquery($sql, array($val));
- $email = $adb->query_result($res,0,'email1');
- if($email == '')
- {
- $email = $adb->query_result($res,0,'email2');
- if($email == '')
- {
- $email = $adb->query_result($res,0,'yahoo_id');
- }
- }
- $adb->println("Email id is selected => '".$email."'");
- return $email;
- }
- else
- {
- $adb->println("User id is empty. so return value is ''");
- return '';
- }
-}
-
-/** Funtion to add the user's signature with the content passed
- * $contents -- where we want to add the signature
- * $fromname -- which user's signature will be added to the contents
- */
-function addSignature($contents, $fromname)
-{
- global $adb;
- $adb->println("Inside the function addSignature");
-
- $sign = nl2br($adb->query_result($adb->pquery("select signature from vtiger_users where user_name=?", array($fromname)),0,"signature"));
- if($sign != '')
- {
- $contents .= '
'.$sign;
- $adb->println("Signature is added with the body => '.".$sign."'");
- }
- else
- {
- $adb->println("Signature is empty for the user => '".$fromname."'");
- }
- return $contents;
-}
-
-/** Function to set all the Mailer properties
- * $mail -- reference of the mail object
- * $subject -- subject of the email you want to send
- * $contents -- body of the email you want to send
- * $from_email -- from email id which will be displayed in the mail
- * $from_name -- from name which will be displayed in the mail
- * $to_email -- to email address -- This can be an email in a single string, a comma separated
- * list of emails or an array of email addresses
- * $attachment -- whether we want to attach the currently selected file or all vtiger_files.
- [values = current,all] - optional
- * $emailid -- id of the email object which will be used to get the vtiger_attachments - optional
- */
-function setMailerProperties($mail,$subject,$contents,$from_email,$from_name,$to_email,$attachment='',$emailid='',$module='',$logo='')
-{
- global $adb;
- $adb->println("Inside the function setMailerProperties");
- if($module == "Support" || $logo ==1)
- $mail->AddEmbeddedImage('themes/images/logo_mail.jpg', 'logo', 'logo.jpg',"base64","image/jpg");
-
- $mail->Subject = $subject;
- $mail->Body = $contents;
- //$mail->Body = html_entity_decode(nl2br($contents)); //if we get html tags in mail then we will use this line
- $mail->AltBody = strip_tags(preg_replace(array("//i","/
/i","/
/i"),array("\n","\n","\n"),$contents));
-
- $mail->IsSMTP(); //set mailer to use SMTP
- //$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
-
- setMailServerProperties($mail);
-
- //Handle the from name and email for HelpDesk
- $mail->From = $from_email;
- $rs = $adb->pquery("select first_name,last_name from vtiger_users where user_name=?", array($from_name));
- if($adb->num_rows($rs) > 0)
- $from_name = $adb->query_result($rs,0,"first_name")." ".$adb->query_result($rs,0,"last_name");
-
- $mail->FromName = decode_html($from_name);
-
- if($to_email != '')
- {
- if(is_array($to_email)) {
- for($j=0,$num=count($to_email);$j<$num;$j++) {
- $mail->addAddress($to_email[$j]);
- }
- } else {
- $_tmp = explode(",",$to_email);
- for($j=0,$num=count($_tmp);$j<$num;$j++) {
- $mail->addAddress($_tmp[$j]);
- }
- }
- }
-
- $mail->AddReplyTo($from_email);
- $mail->WordWrap = 50;
-
- //If we want to add the currently selected file only then we will use the following function
- if($attachment == 'current' && $emailid != '')
- {
- if (isset($_REQUEST['filename_hidden'])) {
- $file_name = $_REQUEST['filename_hidden'];
- } else {
- $file_name = $_FILES['filename']['name'];
- }
- addAttachment($mail,$file_name,$emailid);
- }
-
- //This will add all the vtiger_files which are related to this record or email
- if($attachment == 'all' && $emailid != '')
- {
- addAllAttachments($mail,$emailid);
- }
-
- $mail->IsHTML(true); // set email format to HTML
-
- return;
-}
-
-/** Function to set the Mail Server Properties in the object passed
- * $mail -- reference of the mailobject
- */
-function setMailServerProperties($mail)
-{
- global $adb;
- $adb->println("Inside the function setMailServerProperties");
-
- $res = $adb->pquery("select * from vtiger_systems where server_type=?", array('email'));
- if(isset($_REQUEST['server']))
- $server = $_REQUEST['server'];
- else
- $server = $adb->query_result($res,0,'server');
- if(isset($_REQUEST['server_username']))
- $username = $_REQUEST['server_username'];
- else
- $username = $adb->query_result($res,0,'server_username');
- if(isset($_REQUEST['server_password']))
- $password = $_REQUEST['server_password'];
- else
- $password = $adb->query_result($res,0,'server_password');
- // Prasad: First time read smtp_auth from the request
- if(isset($_REQUEST['smtp_auth']))
- {
- $smtp_auth = $_REQUEST['smtp_auth'];
- if($smtp_auth == 'on')
- $smtp_auth = 'true';
- }
- else if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'Settings' && (!isset($_REQUEST['smtp_auth'])))
- {
- //added to avoid issue while editing the values in the outgoing mail server.
- $smtp_auth = 'false';
- }
- else
- $smtp_auth = $adb->query_result($res,0,'smtp_auth');
-
- $adb->println("Mail server name,username & password => '".$server."','".$username."','".$password."'");
- if($smtp_auth == "true"){
- $mail->SMTPAuth = true; // turn on SMTP authentication
- }
- $mail->Host = $server; // specify main and backup server
- $mail->Username = $username ; // SMTP username
- $mail->Password = $password ; // SMTP password
-
- return;
-}
-
-/** Function to add the file as attachment with the mail object
- * $mail -- reference of the mail object
- * $filename -- filename which is going to added with the mail
- * $record -- id of the record - optional
- */
-function addAttachment($mail,$filename,$record)
-{
- global $adb, $root_directory;
- $adb->println("Inside the function addAttachment");
- $adb->println("The file name is => '".$filename."'");
-
- //This is the file which has been selected in Email EditView
- if(is_file($filename) && $filename != '')
- {
- $mail->AddAttachment($root_directory."test/upload/".$filename);
- }
-}
-
-/** Function to add all the vtiger_files as attachment with the mail object
- * $mail -- reference of the mail object
- * $record -- email id ie., record id which is used to get the all vtiger_attachments from database
- */
-function addAllAttachments($mail,$record)
-{
- global $adb,$log, $root_directory;
- $adb->println("Inside the function addAllAttachments");
-
- //Retrieve the vtiger_files from database where avoid the file which has been currently selected
- $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.deleted=0 and vtiger_seattachmentsrel.crmid=?";
- $res = $adb->pquery($sql, array($record));
- $count = $adb->num_rows($res);
-
- for($i=0;$i<$count;$i++)
- {
- $fileid = $adb->query_result($res,$i,'attachmentsid');
- $filename = decode_html($adb->query_result($res,$i,'name'));
- $filepath = $adb->query_result($res,$i,'path');
- $filewithpath = $root_directory.$filepath.$fileid."_".$filename;
-
- //if the file is exist in test/upload directory then we will add directly
- //else get the contents of the file and write it as a file and then attach (this will occur when we unlink the file)
- if(is_file($filewithpath))
- {
- $mail->AddAttachment($filewithpath,$filename);
- }
- }
-}
-
-/** Function to set the CC or BCC addresses in the mail
- * $mail -- reference of the mail object
- * $cc_mod -- mode to set the address ie., cc or bcc
- * $cc_val -- addresss with comma seperated to set as CC or BCC in the mail
- */
-function setCCAddress($mail,$cc_mod,$cc_val)
-{
- global $adb;
- $adb->println("Inside the functin setCCAddress");
-
- if($cc_mod == 'cc')
- $method = 'AddCC';
- if($cc_mod == 'bcc')
- $method = 'AddBCC';
- if($cc_val != '')
- {
- $ccmail = explode(",",trim($cc_val,","));
- for($i=0;$i");
- }
- if($ccmail[$i] != '')
- $mail->$method($addr,$cc_name);
- }
- }
-}
-
-/** Function to send the mail which will be called after set all the mail object values
- * $mail -- reference of the mail object
- */
-function MailSend($mail)
-{
- global $log;
- $log->info("Inside of Send Mail function.");
- if(!$mail->Send())
- {
- $log->debug("Error in Mail Sending : Error log = '".$mail->ErrorInfo."'");
- return $mail->ErrorInfo;
- }
- else
- {
- $log->info("Mail has been sent from the vtigerCRM system : Status : '".$mail->ErrorInfo."'");
- return 1;
- }
-}
-
-/** Function to get the Parent email id from HelpDesk to send the details about the ticket via email
- * $returnmodule -- Parent module value. Contact or Account for send email about the ticket details
- * $parentid -- id of the parent ie., contact or vtiger_account
- */
-function getParentMailId($parentmodule,$parentid)
-{
- global $adb;
- $adb->println("Inside the function getParentMailId. \n parent module and id => ".$parentmodule."&".$parentid);
-
- if($parentmodule == 'Contacts')
- {
- $tablename = 'vtiger_contactdetails';
- $idname = 'contactid';
- $first_email = 'email';
- $second_email = 'yahooid';
- }
- if($parentmodule == 'Accounts')
- {
- $tablename = 'vtiger_account';
- $idname = 'accountid';
- $first_email = 'email1';
- $second_email = 'email2';
- }
- if($parentid != '')
- {
- //$query = 'select * from '.$tablename.' where '.$idname.' = '.$parentid;
- $query = 'select * from '.$tablename.' where '. $idname.' = ?';
- $res = $adb->pquery($query, array($parentid));
- $mailid = $adb->query_result($res,0,$first_email);
- $mailid2 = $adb->query_result($res,0,$second_email);
- }
- if($mailid == '' && $mailid2 != '')
- $mailid = $mailid2;
-
- return $mailid;
-}
-
-/** Function to parse and get the mail error
- * $mail -- reference of the mail object
- * $mail_status -- status of the mail which is sent or not
- * $to -- the email address to whom we sent the mail and failes
- * return -- Mail error occured during the mail sending process
- */
-function getMailError($mail,$mail_status,$to)
-{
- //Error types in class.phpmailer.php
- /*
- provide_address, mailer_not_supported, execute, instantiate, file_access, file_open, encoding, data_not_accepted, authenticate,
- connect_host, recipients_failed, from_failed
- */
-
- global $adb;
- $adb->println("Inside the function getMailError");
-
- $msg = array_search($mail_status,$mail->language);
- $adb->println("Error message ==> ".$msg);
-
- if($msg == 'connect_host')
- {
- $error_msg = $msg;
- }
- elseif(strstr($msg,'from_failed'))
- {
- $error_msg = $msg;
- }
- elseif(strstr($msg,'recipients_failed'))
- {
- $error_msg = $msg;
- }
- else
- {
- $adb->println("Mail error is not as connect_host or from_failed or recipients_failed");
- //$error_msg = $msg;
- }
-
- $adb->println("return error => ".$error_msg);
- return $error_msg;
-}
-
-/** Function to get the mail status string (string of sent mail status)
- * $mail_status_str -- concatenated string with all the error messages with &&& seperation
- * return - the error status as a encoded string
- */
-function getMailErrorString($mail_status_str)
-{
- global $adb;
- $adb->println("Inside getMailErrorString function.\nMail status string ==> ".$mail_status_str);
-
- $mail_status_str = trim($mail_status_str,"&&&");
- $mail_status_array = explode("&&&",$mail_status_str);
- $adb->println("All Mail status ==>\n".$mail_status_str."\n");
-
- foreach($mail_status_array as $key => $val)
- {
- $list = explode("=",$val);
- $adb->println("Mail id & status ==> ".$list[0]." = ".$list[1]);
- if($list[1] == 0)
- {
- $mail_error_str .= $list[0]."=".$list[1]."&&&";
- }
- }
- $adb->println("Mail error string => '".$mail_error_str."'");
- if($mail_error_str != '')
- {
- $mail_error_str = 'mail_error='.base64_encode($mail_error_str);
- }
- return $mail_error_str;
-}
-
-/** Function to parse the error string
- * $mail_error_str -- base64 encoded string which contains the mail sending errors as concatenated with &&&
- * return - Error message to display
- */
-function parseEmailErrorString($mail_error_str)
-{
- //TODO -- we can modify this function for better email error handling in future
- global $adb, $mod_strings;
- $adb->println("Inside the parseEmailErrorString function.\n encoded mail error string ==> ".$mail_error_str);
-
- $mail_error = base64_decode($mail_error_str);
- $adb->println("Original error string => ".$mail_error);
- $mail_status = explode("&&&",trim($mail_error,"&&&"));
- foreach($mail_status as $key => $val)
- {
- $status_str = explode("=",$val);
- $adb->println('Mail id => "'.$status_str[0].'".........status => "'.$status_str[1].'"');
- if($status_str[1] != 1 && $status_str[1] != '')
- {
- $adb->println("Error in mail sending");
- if($status_str[1] == 'connect_host')
- {
- $adb->println("if part - Mail sever is not configured");
- $errorstr .= '
'.$mod_strings['MESSAGE_CHECK_MAIL_SERVER_NAME'].'';
- break;
- }
- elseif($status_str[1] == '0')
- {
- $adb->println("first elseif part - status will be 0 which is the case of assigned to vtiger_users's email is empty.");
- $errorstr .= '
'.$mod_strings['MESSAGE_MAIL_COULD_NOT_BE_SEND'].' '.$mod_strings['MESSAGE_PLEASE_CHECK_FROM_THE_MAILID'].'';
- //Added to display the message about the CC && BCC mail sending status
- if($status_str[0] == 'cc_success')
- {
- $cc_msg = 'But the mail has been sent to CC & BCC addresses.';
- $errorstr .= '
'.$cc_msg.'';
- }
- }
- elseif(strstr($status_str[1],'from_failed'))
- {
- $adb->println("second elseif part - from email id is failed.");
- $from = explode('from_failed',$status_str[1]);
- $errorstr .= "
".$mod_strings['MESSAGE_PLEASE_CHECK_THE_FROM_MAILID']." '".$from[1]."'";
- }
- else
- {
- $adb->println("else part - mail send process failed due to the following reason.");
- $errorstr .= "
".$mod_strings['MESSAGE_MAIL_COULD_NOT_BE_SEND_TO_THIS_EMAILID']." '".$status_str[0]."'. ".$mod_strings['PLEASE_CHECK_THIS_EMAILID']."";
- }
- }
- }
- $adb->println("Return Error string => ".$errorstr);
- return $errorstr;
-}
-?>
diff --git a/oss/vtiger/trunk/modules/Emails/mailSelect.php b/oss/vtiger/trunk/modules/Emails/mailSelect.php
deleted file mode 100644
index 5bb49f3a..00000000
--- a/oss/vtiger/trunk/modules/Emails/mailSelect.php
+++ /dev/null
@@ -1,109 +0,0 @@
-id;
-
-$querystr = "select fieldid, fieldname, fieldlabel, columnname from vtiger_field where tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
-$res=$adb->pquery($querystr, array(getTabid($pmodule)));
-$numrows = $adb->num_rows($res);
-$returnvalue = Array();
-for($i = 0; $i < $numrows; $i++)
-{
- $value = Array();
- $fieldname = $adb->query_result($res,$i,"fieldname");
- $permit = getFieldVisibilityPermission($pmodule, $userid, $fieldname);
- if($permit == '0')
- {
- $temp=$adb->query_result($res,$i,'columnname');
- $columnlists [] = $temp;
- $fieldid=$adb->query_result($res,$i,'fieldid');
- $fieldlabel =$adb->query_result($res,$i,'fieldlabel');
- $value[] = getTranslatedString($fieldlabel);
- $returnvalue [$fieldid]= $value;
- }
-}
-
-if($single_record && count($columnlists) > 0)
-{
- $count = 0;
- $val_cnt = 0;
- switch($pmodule)
- {
- case 'Accounts':
- $query = 'select accountname,'.implode(",",$columnlists).' from vtiger_account left join vtiger_accountscf on vtiger_accountscf.accountid = vtiger_account.accountid where vtiger_account.accountid = ?';
- $result=$adb->pquery($query, array($idlist));
- foreach($columnlists as $columnname)
- {
- $acc_eval = $adb->query_result($result,0,$columnname);
- $field_value[$count++] = $acc_eval;
- if($acc_eval != "") $val_cnt++;
-
- }
- $entity_name = $adb->query_result($result,0,'accountname');
- break;
- case 'Leads':
- $query = 'select concat(firstname," ",lastname) as leadname,'.implode(",",$columnlists).' from vtiger_leaddetails left join vtiger_leadscf on vtiger_leadscf.leadid = vtiger_leaddetails.leadid where vtiger_leaddetails.leadid = ?';
- $result=$adb->pquery($query, array($idlist));
- foreach($columnlists as $columnname)
- {
- $lead_eval = $adb->query_result($result,0,$columnname);
- $field_value[$count++] = $lead_eval;
- if($lead_eval != "") $val_cnt++;
- }
- $entity_name = $adb->query_result($result,0,'leadname');
- break;
- case 'Contacts':
- $query = 'select concat(firstname," ",lastname) as contactname,'.implode(",",$columnlists).' from vtiger_contactdetails left join vtiger_contactscf on vtiger_contactscf.contactid = vtiger_contactdetails.contactid where vtiger_contactdetails.contactid = ?';
- $result=$adb->pquery($query, array($idlist));
- foreach($columnlists as $columnname)
- {
- $con_eval = $adb->query_result($result,0,$columnname);
- $field_value[$count++] = $con_eval;
- if($con_eval != "") $val_cnt++;
- }
- $entity_name = $adb->query_result($result,0,'contactname');
- break;
- }
-}
-$smarty->assign('PERMIT',$permit);
-$smarty->assign('ENTITY_NAME',$entity_name);
-$smarty->assign('ONE_RECORD',$single_record);
-$smarty->assign('MAILDATA',$field_value);
-$smarty->assign('MAILINFO',$returnvalue);
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("IDLIST", $idlist);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("FROM_MODULE", $pmodule);
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH",$image_path);
-if($single_record && count($columnlists) > 0 && $val_cnt > 0)
- $smarty->display("SelectEmail.tpl");
-else if(!$single_record && count($columnlists) > 0)
- $smarty->display("SelectEmail.tpl");
-else if($single_record && $val_cnt == 0)
- echo "No Mail Ids";
-else
- echo "Mail Ids not permitted";
-?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Emails/mailsend.php b/oss/vtiger/trunk/modules/Emails/mailsend.php
deleted file mode 100644
index bcc14e7f..00000000
--- a/oss/vtiger/trunk/modules/Emails/mailsend.php
+++ /dev/null
@@ -1,239 +0,0 @@
-id;//$_REQUEST['record'];
-}
-
-
-$adb->println("\n\nMail Sending Process has been started.");
-//This function call is used to send mail to the assigned to user. In this mail CC and BCC addresses will be added.
-if($_REQUEST['assigntype' == 'T'] && $_REQUEST['assigned_group_id']!='')
-{
- $grp_obj = new GetGroupUsers();
- $grp_obj->getAllUsersInGroup($_REQUEST['assigned_group_id']);
- $users_list = constructList($grp_obj->group_users,'INTEGER');
- if (count($users_list) > 0) {
- $sql = "select first_name, last_name, email1, email2, yahoo_id from vtiger_users where id in (". generateQuestionMarks($users_list) .")";
- $params = array($users_list);
- } else {
- $sql = "select first_name, last_name, email1, email2, yahoo_id from vtiger_users";
- $params = array();
- }
- $res = $adb->pquery($sql, $params);
- $user_email = '';
- while ($user_info = $adb->fetch_array($res))
- {
- $email = $user_info['email1'];
- if($email == '' || $email == 'NULL')
- {
- $email = $user_info['email2'];
- if($email == '' || $email == 'NULL')
- {
- $email = $user_info['yahoo_id'];
- }
- }
- if($user_email=='')
- $user_email .= $user_info['first_name']." ".$user_info['last_name']."<".$email.">";
- else
- $user_email .= ",".$user_info['first_name']." ".$user_info['last_name']."<".$email.">";
- $email='';
- }
- $to_email = $user_email;
-}
-else
-{
- $to_email = getUserEmailId('id',$focus->column_fields["assigned_user_id"]);
-}
-$cc = $_REQUEST['ccmail'];
-$bcc = $_REQUEST['bccmail'];
-if($to_email == '' && $cc == '' && $bcc == '')
-{
- $adb->println("Mail Error : send_mail function not called because To email id of assigned to user, CC and BCC are empty");
- $mail_status_str = "'".$to_email."'=0&&&";
- $errorheader1 = 1;
-}
-else
-{
- $query1 = "select email1 from vtiger_users where id =?";
- $res1 = $adb->pquery($query1, array($current_user->id));
- $val = $adb->query_result($res1,0,"email1");
-// $mail_status = send_mail('Emails',$to_email,$current_user->user_name,'',$_REQUEST['subject'],$_REQUEST['description'],$cc,$bcc,'all',$focus->id);
-
- $query = 'update vtiger_emaildetails set email_flag ="SENT",from_email =? where emailid=?';
- $adb->pquery($query, array($val, $focus->id));
- //set the errorheader1 to 1 if the mail has not been sent to the assigned to user
- if($mail_status != 1)//when mail send fails
- {
- $errorheader1 = 1;
- $mail_status_str = $to_email."=".$mail_status."&&&";
- }
- elseif($mail_status == 1 && $to_email == '')//Mail send success only for CC and BCC but the 'to' email is empty
- {
- $adb->pquery($query, array($val, $focus->id));
- $errorheader1 = 1;
- $mail_status_str = "cc_success=0&&&";
- }
- else
- {
- $mail_status_str = $to_email."=".$mail_status."&&&";
- }
-}
-
-
-//Added code from mysendmail.php which is contributed by Raju(rdhital)
-$parentid= $_REQUEST['parent_id'];
-$myids=explode("|",$parentid);
-$all_to_emailids = Array();
-$from_name = $current_user->user_name;
-$from_address = $current_user->column_fields['email1'];
-
-for ($i=0;$i<(count($myids)-1);$i++)
-{
- $realid=explode("@",$myids[$i]);
- $nemail=count($realid);
- $mycrmid=$realid[0];
- if($realid[1] == -1)
- {
- //handle the mail send to vtiger_users
- $emailadd = $adb->query_result($adb->pquery("select email1 from vtiger_users where id=?", array($mycrmid)),0,'email1');
- $pmodule = 'Users';
- $description = getMergedDescription($_REQUEST['description'],$mycrmid,$pmodule);
- $mail_status = send_mail('Emails',$emailadd,$from_name,$from_address,$_REQUEST['subject'],$description,'','','all',$focus->id);
- $all_to_emailids []= $emailadd;
- $mail_status_str .= $emailadd."=".$mail_status."&&&";
- }
- else
- {
- //Send mail to vtiger_account or lead or contact based on their ids
- $pmodule=getSalesEntityType($mycrmid);
- for ($j=1;$j<$nemail;$j++)
- {
- $temp=$realid[$j];
- $myquery='Select columnname from vtiger_field where fieldid = ? and vtiger_field.presence in (0,2)';
- $fresult=$adb->pquery($myquery, array($temp));
- if ($pmodule=='Contacts')
- {
- require_once('modules/Contacts/Contacts.php');
- $myfocus = new Contacts();
- $myfocus->retrieve_entity_info($mycrmid,"Contacts");
- }
- elseif ($pmodule=='Accounts')
- {
- require_once('modules/Accounts/Accounts.php');
- $myfocus = new Accounts();
- $myfocus->retrieve_entity_info($mycrmid,"Accounts");
- }
- elseif ($pmodule=='Leads')
- {
- require_once('modules/Leads/Leads.php');
- $myfocus = new Leads();
- $myfocus->retrieve_entity_info($mycrmid,"Leads");
- }
- elseif ($pmodule=='Vendors')
- {
- require_once('modules/Vendors/Vendors.php');
- $myfocus = new Vendors();
- $myfocus->retrieve_entity_info($mycrmid,"Vendors");
- }
- else {
- // vtlib customization: Enabling mail send from other modules
- $myfocus = CRMEntity::getInstance($pmodule);
- $myfocus->retrieve_entity_info($mycrmid, $pmodule);
- // END
- }
- $fldname=$adb->query_result($fresult,0,"columnname");
- $emailadd=br2nl($myfocus->column_fields[$fldname]);
-
-//This is to convert the html encoded string to original html entities so that in mail description contents will be displayed correctly
- //$focus->column_fields['description'] = from_html($focus->column_fields['description']);
-
- if($emailadd != '')
- {
- $description = getMergedDescription($_REQUEST['description'],$mycrmid,$pmodule);
- //Email Open Tracking
- global $site_URL, $application_unique_key;
- $emailid = $focus->id;
- $track_URL = "$site_URL/modules/Emails/TrackAccess.php?record=$mycrmid&mailid=$emailid&app_key=$application_unique_key";
- $description = "
$description";
- // END
-
- $pos = strpos($description, '$logo$');
- if ($pos !== false)
- {
-
- $description =str_replace('$logo$','
',$description);
- $logo=1;
- }
- if(isPermitted($pmodule,'DetailView',$mycrmid) == 'yes')
- {
- $mail_status = send_mail('Emails',$emailadd,$from_name,$from_address,$_REQUEST['subject'],$description,'','','all',$focus->id,$logo);
- }
-
- $all_to_emailids []= $emailadd;
- $mail_status_str .= $emailadd."=".$mail_status."&&&";
- //added to get remain the EditView page if an error occurs in mail sending
- if($mail_status != 1)
- {
- $errorheader2 = 1;
- }
- }
- }
- }
-
-}
-//Added to redirect the page to Emails/EditView if there is an error in mail sending
-if($errorheader1 == 1 || $errorheader2 == 1)
-{
- $returnset = 'return_module='.$returnmodule.'&return_action='.$returnaction.'&return_id='.vtlib_purify($_REQUEST['return_id']);
- $returnmodule = 'Emails';
- $returnaction = 'EditView';
- //This condition is added to set the record(email) id when we click on send mail button after returning mail error
- if($_REQUEST['mode'] == 'edit')
- {
- $returnid = $_REQUEST['record'];
- }
- else
- {
- $returnid = $_REQUEST['currentid'];
- }
-}
-else
-{
- global $adb;
- $date_var = date('Ymd');
- $query = 'update vtiger_activity set date_start =? where activityid = ?';
- $adb->pquery($query, array($date_var, $returnid));
-}
-//The following function call is used to parse and form a encoded error message and then pass to result page
-$mail_error_str = getMailErrorString($mail_status_str);
-$adb->println("Mail Sending Process has been finished.\n\n");
-if(isset($_REQUEST['popupaction']) && $_REQUEST['popupaction'] != '')
-{
- /*this will fix #1211*/
- $inputs="";
- //$inputs="";
- echo $inputs;
-}
-?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Emails/templates/testemailtemplateusage.php b/oss/vtiger/trunk/modules/Emails/templates/testemailtemplateusage.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/oss/vtiger/trunk/modules/Emails/templates/todel.txt b/oss/vtiger/trunk/modules/Emails/templates/todel.txt
deleted file mode 100644
index e69de29b..00000000
diff --git a/oss/vtiger/trunk/modules/Emails/updateRelations.php b/oss/vtiger/trunk/modules/Emails/updateRelations.php
deleted file mode 100644
index 14be6cbe..00000000
--- a/oss/vtiger/trunk/modules/Emails/updateRelations.php
+++ /dev/null
@@ -1,40 +0,0 @@
-pquery($sql, array($id, $record));
- }
-}
-if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] != '')
-{
- $record = $_REQUEST['record'];
- $sql = "insert into vtiger_salesmanactivityrel values (?,?)";
- $adb->pquery($sql, array($_REQUEST["user_id"], $record));
-}
-
-header("Location: index.php?action=CallRelatedList&module=Emails&record=".vtlib_purify($record));
-
-?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Emails/webmailsend.php b/oss/vtiger/trunk/modules/Emails/webmailsend.php
deleted file mode 100644
index 1c54392d..00000000
--- a/oss/vtiger/trunk/modules/Emails/webmailsend.php
+++ /dev/null
@@ -1,61 +0,0 @@
-user_name;
- $from_add = $current_user->column_fields['email1'];
- }
- else{
- $from_arr = explode('@',$_REQUEST['from_add']);
- $from_name = $from_arr[0];
- $from_add = $_REQUEST['from_add'];
- }
-$mail_status = send_mail('Emails',$_REQUEST["parent_name"],$from_name,$from_add,$_REQUEST['subject'],$_REQUEST['description'],$_REQUEST["ccmail"],$_REQUEST["bccmail"],'all',$focus->id);
-
-$query = "update vtiger_emaildetails set email_flag ='SENT' where emailid=?";
-$adb->pquery($query, array($focus->id));
-
-//set the errorheader1 to 1 if the mail has not been sent to the assigned to user
-if($mail_status != 1) { //when mail send fails
- $errorheader1 = 1;
- $mail_status_str = $to_email."=".$mail_status."&&&";
-
-} elseif($mail_status == 1 && $to_email == '') { //Mail send success only for CC and BCC but the 'to' email is empty
- $adb->pquery($query, array($focus->id));
- $errorheader1 = 1;
- $mail_status_str = "cc_success=0&&&";
-} else
- $mail_status_str = $to_email."=".$mail_status."&&&";
-
-
-
-//Added to redirect the page to Emails/EditView if there is an error in mail sending
-if($errorheader1 == 1 || $errorheader2 == 1)
-{
- $returnset = 'return_module='.$returnmodule.'&return_action='.$returnaction.'&return_id='.vtlib_purify($_REQUEST['return_id']);
- $returnmodule = 'Emails';
- $returnaction = 'EditView';
- if($_REQUEST['mode'] == 'edit')
- $returnid = $_REQUEST['record'];
- else
- $returnid = $_REQUEST['currentid'];
-}
-
-//The following function call is used to parse and form a encoded error message and then pass to result page
-$mail_error_str = getMailErrorString($mail_status_str);
-$adb->println("Mail Sending Process has been finished.\n\n");
-
-if(isset($_REQUEST['popupaction']) && $_REQUEST['popupaction'] != '')
-{
- $inputs="";
- echo $inputs;
-}
-?>