';
+ }
+
+ /**
+ * Takes over from PHP for the socket warning handler
+ * @access private
+ * @param integer $errno
+ * @param string $errstr
+ * @param string $errfile
+ * @param integer $errline
+ */
+ private function catchWarning ($errno, $errstr, $errfile, $errline) {
+ $this->error[] = array(
+ 'error' => "Connecting to the POP3 server raised a PHP warning: ",
+ 'errno' => $errno,
+ 'errstr' => $errstr
+ );
+ }
+
+ // End of class
+}
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/class.smtp.php b/gulliver/thirdparty/phpmailer/class.smtp.php
index ae903ca34..125f85348 100644
--- a/gulliver/thirdparty/phpmailer/class.smtp.php
+++ b/gulliver/thirdparty/phpmailer/class.smtp.php
@@ -1,1045 +1,816 @@
smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
+ /**
+ * Sets VERP use on/off (default is off)
+ * @var bool
+ */
+ public $do_verp = false;
- $this->do_debug = 0;
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE AND PROTECTED
+ /////////////////////////////////////////////////
+
+ private $smtp_conn; // the socket to the server
+ public $error; // error if any on the last call
+ private $helo_rply; // the reply the server sent to us for HELO
+
+ var $status;
+
+ /**
+ * Initialize the class so that the data is in a known state.
+ * @access public
+ * @return void
+ */
+ public function __construct() {
+ $this->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
+ */
+ public 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()) {
+ // already connected, generate error
+ $this->error = array("error" => "Already connected to a server");
+ return false;
}
- /*************************************************************
- * 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
- $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
- # 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 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;
+ if(empty($port)) {
+ $port = $this->SMTP_PORT;
}
- /**
- * 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;
+ // connect to the smtp server
+ $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
+ // 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;
}
- /**
- * 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;
+ // SMTP server can take longer to respond, give longer timeout for first read
+ // Windows 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 announcement
+ $announce = $this->get_lines();
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . ' ';
+ }
+ $this->status = $this->CRLF . $announce;
+ return true;
+ }
+
+ /**
+ * Initiate a TLS communication with the server.
+ *
+ * SMTP CODE 220 Ready to start TLS
+ * SMTP CODE 501 Syntax error (no parameters allowed)
+ * SMTP CODE 454 TLS not available due to temporary reason
+ * @access public
+ * @return bool success
+ */
+ public function StartTLS() {
+ $this->error = null; # to avoid confusion
+
+ if(!$this->connected()) {
+ $this->error = array("error" => "Called StartTLS() without being connected");
+ 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;
- }
+ fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . ' ';
}
-
- /***************************************************************
- * 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 headers. Each header needs to be
- * on a single line followed by a with the message 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 headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg headers
- # and if the first 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
- # 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 headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg 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;
+ if($code != 220) {
+ $this->error =
+ array("error" => "STARTTLS 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;
}
- /**
- * 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;
+ // Begin encrypted connection
+ if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
+ return false;
}
- /**
- * 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
+ return true;
+ }
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Hello() without being connected");
- return false;
- }
+ /**
+ * Performs SMTP authentication. Must be run after running the
+ * Hello() method. Returns true if successfully authenticated.
+ * @access public
+ * @return bool
+ */
+ public function Authenticate($username, $password) {
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
- # 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";
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- // Send extended hello first (RFC 2821)
- if(!$this->SendHello("EHLO", $host))
- {
- if(!$this->SendHello("HELO", $host))
- return false;
- }
-
- return true;
+ 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;
}
- /**
- * Sends a HELO/EHLO command.
- * @access private
- * @return bool
- */
- function SendHello($hello, $host) {
- @fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ $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;
+ 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;
}
- /**
- * 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
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Help() without being connected");
- return false;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- $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;
+ 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;
}
- /**
- * 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
+ return true;
+ }
- 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 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 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 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");
+ /**
+ * Returns true if connected to a server otherwise false
+ * @access public
+ * @return bool
+ */
+ public function Connected() {
+ if(!empty($this->smtp_conn)) {
+ $sock_status = socket_get_status($this->smtp_conn);
+ if($sock_status["eof"]) {
+ // the socket is valid but we are not connected
if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ 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
+ */
+ public 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 headers. Each header needs to be
+ * on a single line followed by a with the message 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
+ */
+ public 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;
}
- /**
- * 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
+ 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:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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 limit.
*/
- 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;
- }
+ // 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);
- 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
+ /* we need to find a good way to determine is headers are
+ * in the msg_data or if it is a straight msg body
+ * currently I am assuming rfc 822 definitions of msg headers
+ * and if the first 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
+ * headers.
*/
- 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;
+
+ $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);
+ } else {
+ $lines_out[] = substr($line,0,$pos);
+ $line = substr($line,$pos + 1);
+ }
+
+ /* if processing headers add a LWSP-char to the front of new line
+ * rfc 822 on long msg headers
+ */
+ if($in_headers) {
+ $line = "\t" . $line;
+ }
+ }
+ $lines_out[] = $line;
+
+ // 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);
+ }
+ }
+
+ // message data has been sent
+ 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:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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;
+ }
+
+ /**
+ * 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
+ */
+ public 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 hostname for HELO was not specified send default
+ if(empty($host)) {
+ // determine appropriate default to send to 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
+ */
+ private 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: " . $rply . $this->CRLF . ' ';
+ }
+
+ 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;
+ }
+
+ /**
+ * 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
+ */
+ public 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;
+ }
+
+ $useVerp = ($this->do_verp ? "XVERP" : "");
+ fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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 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
+ */
+ public 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:" . $byemsg . $this->CRLF . ' ';
+ }
+
+ $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
+ */
+ public 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:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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
+ */
+ public 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:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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 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
+ */
+ public 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:" . $rply . $this->CRLF . ' ';
+ }
+
+ 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;
+ }
+
+ /**
+ * 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
+ */
+ public 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;
+ }
+
+ /**
+ * Get the current error
+ * @access public
+ * @return array
+ */
+ public function getError() {
+ return $this->error;
+ }
+
+ /////////////////////////////////////////////////
+ // 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
+ */
+ private 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 4th character is a space, we are done reading, break the loop
+ if(substr($str,3,1) == " ") { break; }
+ }
+ return $data;
+ }
+
}
-
- ?>
+?>
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ar.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ar.php
new file mode 100644
index 000000000..b7c5057d0
--- /dev/null
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ar.php
@@ -0,0 +1,27 @@
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.';
+$PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: لم يتم قبول المعلومات .';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: ';
+$PHPMAILER_LANG['execute'] = 'لم أستطع تنفيذ : ';
+$PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للملف: ';
+$PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: ';
+$PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : ';
+$PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.';
+//$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' .
+ 'فشل في الارسال لكل من : ';
+$PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-br.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-br.php
index 0ff6c1693..7d64ce4d4 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-br.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-br.php
@@ -1,21 +1,26 @@
-
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ca.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ca.php
index 819902ede..1127567dc 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ca.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ca.php
@@ -1,22 +1,26 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ch.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ch.php
new file mode 100644
index 000000000..31ebd861c
--- /dev/null
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ch.php
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-cz.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-cz.php
index 714ed6bd5..f9589ca19 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-cz.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-cz.php
@@ -1,24 +1,25 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-de.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-de.php
index d21836ad0..165a86f4f 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-de.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-de.php
@@ -1,23 +1,25 @@
-
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-dk.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-dk.php
index 0233492c3..59b58c0fc 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-dk.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-dk.php
@@ -1,24 +1,26 @@
-
- */
-
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'Du skal indtaste mindst en ' .
- 'modtagers emailadresse.';
-$PHPMAILER_LANG["mailer_not_supported"] = ' mailer understøttes ikke.';
-$PHPMAILER_LANG["execute"] = 'Kunne ikke køre: ';
-$PHPMAILER_LANG["instantiate"] = 'Kunne ikke initialisere email funktionen.';
-$PHPMAILER_LANG["authenticate"] = 'SMTP fejl: Kunne ikke logge på.';
-$PHPMAILER_LANG["from_failed"] = 'Følgende afsenderadresse er forkert: ';
-$PHPMAILER_LANG["recipients_failed"] = 'SMTP fejl: Følgende' .
- 'modtagere er forkerte: ';
-$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fejl: Data kunne ikke accepteres.';
-$PHPMAILER_LANG["connect_host"] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.';
-$PHPMAILER_LANG["file_access"] = 'Ingen adgang til fil: ';
-$PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke åbne filen: ';
-$PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: ';
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Kunne ikke logge på.';
+$PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data kunne ikke accepteres.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: ';
+$PHPMAILER_LANG['execute'] = 'Kunne ikke køre: ';
+$PHPMAILER_LANG['file_access'] = 'Ingen adgang til fil: ';
+$PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: ';
+$PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: ';
+$PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere email funktionen.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.';
+$PHPMAILER_LANG['provide_address'] = 'Du skal indtaste mindst en modtagers emailadresse.';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-es.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-es.php
index 0c65bb1d2..0b6982509 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-es.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-es.php
@@ -1,23 +1,26 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-et.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-et.php
new file mode 100644
index 000000000..cf61779b0
--- /dev/null
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-et.php
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fi.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fi.php
index d881080d4..6d7dccee5 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fi.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fi.php
@@ -1,23 +1,27 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fo.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fo.php
index fffe19cbb..704c4772d 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fo.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fo.php
@@ -1,25 +1,27 @@
+$PHPMAILER_LANG['authenticate'] = 'SMTP feilur: Kundi ikki góðkenna.';
+$PHPMAILER_LANG['connect_host'] = 'SMTP feilur: Kundi ikki knýta samband við SMTP vert.';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP feilur: Data ikki góðkent.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Ókend encoding: ';
+$PHPMAILER_LANG['execute'] = 'Kundi ikki útføra: ';
+$PHPMAILER_LANG['file_access'] = 'Kundi ikki tilganga fílu: ';
+$PHPMAILER_LANG['file_open'] = 'Fílu feilur: Kundi ikki opna fílu: ';
+$PHPMAILER_LANG['from_failed'] = 'fylgjandi Frá/From adressa miseydnaðist: ';
+$PHPMAILER_LANG['instantiate'] = 'Kuni ikki instantiera mail funktión.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['mailer_not_supported'] = ' er ikki supporterað.';
+$PHPMAILER_LANG['provide_address'] = 'Tú skal uppgeva minst móttakara-emailadressu(r).';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feilur: Fylgjandi móttakarar miseydnaðust: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fr.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fr.php
index 57f414b5f..52e9ae2b9 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fr.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-fr.php
@@ -1,24 +1,25 @@
-
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-hu.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-hu.php
index 4b55a6a46..a26648484 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-hu.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-hu.php
@@ -1,23 +1,25 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-it.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-it.php
index 26ef64dd1..59bf4fb97 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-it.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-it.php
@@ -1,28 +1,27 @@
-
-*/
-
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'Deve essere fornito almeno un'.
- ' indirizzo ricevente';
-$PHPMAILER_LANG["mailer_not_supported"] = 'Mailer non supportato';
-$PHPMAILER_LANG["execute"] = "Impossibile eseguire l'operazione: ";
-$PHPMAILER_LANG["instantiate"] = 'Impossibile istanziare la funzione mail';
-$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Impossibile autenticarsi.';
-$PHPMAILER_LANG["from_failed"] = 'I seguenti indirizzi mittenti hanno'.
- ' generato errore: ';
-$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: I seguenti indirizzi'.
- 'destinatari hanno generato errore: ';
-$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data non accettati dal'.
- 'server.';
-$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Impossibile connettersi'.
- ' all\'host SMTP.';
-$PHPMAILER_LANG["file_access"] = 'Impossibile accedere al file: ';
-$PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il file: ';
-$PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: ';
-?>
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.';
+$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Data non accettati dal server.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Encoding set dei caratteri sconosciuto: ';
+$PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: ';
+$PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: ';
+$PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: ';
+$PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: ';
+$PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente';
+$PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi destinatari hanno generato errore: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ja.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ja.php
index 837a0f58a..66da1b6a1 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ja.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ja.php
@@ -1,25 +1,26 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-nl.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-nl.php
index 13aa73362..355dcdc49 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-nl.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-nl.php
@@ -1,23 +1,25 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-no.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-no.php
index ffaa2e754..bf2f84ee9 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-no.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-no.php
@@ -1,23 +1,25 @@
-
+
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-pl.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-pl.php
index 5691eaf7e..e8bd5124d 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-pl.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-pl.php
@@ -1,24 +1,25 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ro.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ro.php
index a330b4ad6..17cddb76b 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ro.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ro.php
@@ -1,23 +1,27 @@
-
- */
-
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).';
-$PHPMAILER_LANG["mailer_not_supported"] = ' mailer nu este suportat.';
-$PHPMAILER_LANG["execute"] = 'Nu pot executa: ';
-$PHPMAILER_LANG["instantiate"] = 'Nu am putut instantia functia mail.';
-$PHPMAILER_LANG["authenticate"] = 'Eroare SMTP: Nu a functionat autentificarea.';
-$PHPMAILER_LANG["from_failed"] = 'Urmatoarele adrese From au dat eroare: ';
-$PHPMAILER_LANG["recipients_failed"] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: ';
-$PHPMAILER_LANG["data_not_accepted"] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.';
-$PHPMAILER_LANG["connect_host"] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.';
-$PHPMAILER_LANG["file_access"] = 'Nu pot accesa fisierul: ';
-$PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fisierul: ';
-$PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: ';
-?>
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'Eroare SMTP: Nu a functionat autentificarea.';
+$PHPMAILER_LANG['connect_host'] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.';
+$PHPMAILER_LANG['data_not_accepted'] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Encodare necunoscuta: ';
+$PHPMAILER_LANG['execute'] = 'Nu pot executa: ';
+$PHPMAILER_LANG['file_access'] = 'Nu pot accesa fisierul: ';
+$PHPMAILER_LANG['file_open'] = 'Eroare de fisier: Nu pot deschide fisierul: ';
+$PHPMAILER_LANG['from_failed'] = 'Urmatoarele adrese From au dat eroare: ';
+$PHPMAILER_LANG['instantiate'] = 'Nu am putut instantia functia mail.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.';
+$PHPMAILER_LANG['provide_address'] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).';
+$PHPMAILER_LANG['recipients_failed'] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ru.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ru.php
index 3c7d78431..295a56ef4 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ru.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-ru.php
@@ -1,23 +1,25 @@
+*/
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'Ïîæàëóéñòà ââåäèòå ìèíèìóì îäèí Email' .
- 'ïîëó÷àòåëÿ.';
-$PHPMAILER_LANG["mailer_not_supported"] = ' mailer íå ïîääåðæèâàåòñÿ.';
-$PHPMAILER_LANG["execute"] = 'Íåâîçìîæíî âûïîëíèòü ýòó êîìàíäó: ';
-$PHPMAILER_LANG["instantiate"] = 'Ïðîèçîøëà îøèáêà ïðè èíèöèàëèçàöèè Mail ôóíêöèè.';
-$PHPMAILER_LANG["authenticate"] = 'SMTP îøèáêà: îøèáêà àâòîðèçàöèè.';
-$PHPMAILER_LANG["from_failed"] = 'Íåâåðíûé àäðåñ îòïðàâèòåëÿ: ';
-$PHPMAILER_LANG["recipients_failed"] = 'SMTP îøèáêà: Ñëåäóþùèå ' .
- 'àäðåñà ïîëó÷àòåëåé íåâåðíû: ';
-$PHPMAILER_LANG["data_not_accepted"] = 'SMTP îøèáêà: Äàííûå íå áûëè ïðèíÿòû.';
-$PHPMAILER_LANG["connect_host"] = 'SMTP îøèáêà: SMTP-Host íåäîñòóïåí.';
-$PHPMAILER_LANG["file_access"] = 'Â äîñòóïå ê ñëåäóþùåìó ôàéëó áûëî îòêàçàíî: ';
-$PHPMAILER_LANG["file_open"] = 'Íå ìîãó îòêðûòü ôàéë: ';
-$PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé ôîðìàò êîäèðîâêè: ';
-?>
+$PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.';
+$PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к серверу SMTP.';
+$PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Неизвестный вид кодировки: ';
+$PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: ';
+$PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: ';
+$PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удается открыть файл: ';
+$PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: ';
+$PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один адрес e-mail получателя.';
+$PHPMAILER_LANG['mailer_not_supported'] = ' - почтовый сервер не поддерживается.';
+$PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: отправка по следующим адресам получателей не удалась: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-se.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-se.php
index f71326fdb..d459667f7 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-se.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-se.php
@@ -1,24 +1,26 @@
-
- */
-
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'Du måste ange minst en ' .
- 'mottagares e-postadress.';
-$PHPMAILER_LANG["mailer_not_supported"] = ' mailer stöds inte.';
-$PHPMAILER_LANG["execute"] = 'Kunde inte köra: ';
-$PHPMAILER_LANG["instantiate"] = 'Kunde inte initiera e-postfunktion.';
-$PHPMAILER_LANG["authenticate"] = 'SMTP fel: Kunde inte autentisera.';
-$PHPMAILER_LANG["from_failed"] = 'Följande avsändaradress är felaktig: ';
-$PHPMAILER_LANG["recipients_failed"] = 'SMTP fel: Följande ' .
- 'mottagare är felaktig: ';
-$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fel: Data accepterades inte.';
-$PHPMAILER_LANG["connect_host"] = 'SMTP fel: Kunde inte ansluta till SMTP-server.';
-$PHPMAILER_LANG["file_access"] = 'Ingen åtkomst till fil: ';
-$PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte öppna fil: ';
-$PHPMAILER_LANG["encoding"] = 'Okänt encode-format: ';
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP fel: Kunde inte autentisera.';
+$PHPMAILER_LANG['connect_host'] = 'SMTP fel: Kunde inte ansluta till SMTP-server.';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fel: Data accepterades inte.';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = 'Okänt encode-format: ';
+$PHPMAILER_LANG['execute'] = 'Kunde inte köra: ';
+$PHPMAILER_LANG['file_access'] = 'Ingen åtkomst till fil: ';
+$PHPMAILER_LANG['file_open'] = 'Fil fel: Kunde inte öppna fil: ';
+$PHPMAILER_LANG['from_failed'] = 'Följande avsändaradress är felaktig: ';
+$PHPMAILER_LANG['instantiate'] = 'Kunde inte initiera e-postfunktion.';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.';
+$PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: ';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-tr.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-tr.php
index 42b6ea6ab..8a069d14d 100644
--- a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-tr.php
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-tr.php
@@ -1,25 +1,27 @@
-
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh.php
new file mode 100644
index 000000000..fef66f8cb
--- /dev/null
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh.php
@@ -0,0 +1,26 @@
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登錄失敗。';
+$PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。';
+//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = '未知編碼: ';
+$PHPMAILER_LANG['file_access'] = '無法訪問文件:';
+$PHPMAILER_LANG['file_open'] = '文件錯誤:無法打開文件:';
+$PHPMAILER_LANG['from_failed'] = '發送地址錯誤:';
+$PHPMAILER_LANG['execute'] = '無法執行:';
+$PHPMAILER_LANG['instantiate'] = '未知函數調用。';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。';
+$PHPMAILER_LANG['mailer_not_supported'] = '發信客戶端不被支持。';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh_cn.php b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh_cn.php
new file mode 100644
index 000000000..b18840435
--- /dev/null
+++ b/gulliver/thirdparty/phpmailer/language/phpmailer.lang-zh_cn.php
@@ -0,0 +1,26 @@
+
+*/
+
+$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。';
+$PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。';
+$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。';
+//$P$PHPMAILER_LANG['empty_message'] = 'Message body empty';
+$PHPMAILER_LANG['encoding'] = '未知编码: ';
+$PHPMAILER_LANG['execute'] = '无法执行:';
+$PHPMAILER_LANG['file_access'] = '无法访问文件:';
+$PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:';
+$PHPMAILER_LANG['from_failed'] = '发送地址错误:';
+$PHPMAILER_LANG['instantiate'] = '未知函数调用。';
+//$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: ';
+$PHPMAILER_LANG['mailer_not_supported'] = '发信客户端不被支持。';
+$PHPMAILER_LANG['provide_address'] = '必须提供至少一个收件人地址。';
+$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:';
+//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
+//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
+//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
+//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
+?>
\ No newline at end of file
diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php
index 10adb37eb..54d5d1d03 100644
--- a/workflow/engine/classes/class.case.php
+++ b/workflow/engine/classes/class.case.php
@@ -4146,11 +4146,13 @@ class Cases {
$sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
$oSpool = new spoolRun();
$oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],
- 'MESS_SERVER' => $aConfiguration['MESS_SERVER'],
- 'MESS_PORT' => $aConfiguration['MESS_PORT'],
- 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],
+ 'MESS_SERVER' => $aConfiguration['MESS_SERVER'],
+ 'MESS_PORT' => $aConfiguration['MESS_PORT'],
+ 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],
'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],
- 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false));
+ 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,
+ 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''
+ ));
$oSpool->create(array('msg_uid' => '',
'app_uid' => $sApplicationUID,
'del_index' => $iDelegation,
@@ -4163,7 +4165,8 @@ class Cases {
'app_msg_bcc' => '',
'app_msg_attach' => '',
'app_msg_template' => '',
- 'app_msg_status' => 'pending'));
+ 'app_msg_status' => 'pending'
+ ));
if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
$oSpool->sendMail();
}
diff --git a/workflow/engine/classes/class.insert.php b/workflow/engine/classes/class.insert.php
deleted file mode 100644
index f52ed91e0..000000000
--- a/workflow/engine/classes/class.insert.php
+++ /dev/null
@@ -1,105 +0,0 @@
-
- * @copyright Copyright (c) 2007, Ian K Armstrong
- * @license http://www.opensource.org/licenses/gpl-3.0.html GNU Public License
- * @link http://www.openmail.cc
- *
- * @category web_mail
- * @subpackage send
- * @filesource
- * @version
- *
- * @file class.insert.php
- *
- */
-
- require_once ( "classes/model/AppMessage.php" );
-
-class insert
-{
- private $db_spool;
- private $status;
-
- /**
- * construct of insert
- *
- * @param string $pPRO_UID
- * @return void
- */
- function __construct($db_spool=array())
- {
- if(count($db_spool)>0)
- $db_spool = $this->db_insert($db_spool);
-
- }
-
- /**
- * returnStatus
- *
- * @return $this->status;
- */
- public function returnStatus()
- {
- return $this->status;
-
- }
-
- /**
- * db_insert
- *
- * @param array $db_spool
- * @return string $sUID;
- */
- public function db_insert($db_spool)
- {
- $sUID = G::generateUniqueID();
- $spool = new AppMessage();
- $spool->setAppMsgUid($sUID);
- $spool->setMsgUid($db_spool['msg_uid']);
- $spool->setAppUid($db_spool['app_uid']);
- $spool->setDelIndex($db_spool['del_index']);
- $spool->setAppMsgType($db_spool['app_msg_type']);
- $spool->setAppMsgSubject($db_spool['app_msg_subject']);
- $spool->setAppMsgFrom($db_spool['app_msg_from']);
- $spool->setAppMsgTo($db_spool['app_msg_to']);
- $spool->setAppMsgBody($db_spool['app_msg_body']);
- $spool->setAppMsgDate(date('Y-m-d H:i:s'));
- $spool->setAppMsgCc($db_spool['app_msg_cc']);
- $spool->setAppMsgBcc($db_spool['app_msg_bcc']);
- $spool->setappMsgAttach($db_spool['app_msg_attach']);
- $spool->setAppMsgTemplate($db_spool['app_msg_template']);
- $spool->setAppMsgStatus($db_spool['app_msg_status']);
- $spool->setAppMsgSendDate(date('Y-m-d H:i:s')); // Add by Ankit
-
- if(!$spool->validate()) {
- $errors = $spool->getValidationFailures();
- $this->status = 'error';
-
- foreach($errors as $key => $value) {
- echo "Validation error - " . $value->getMessage($key) . "\n";
- }
- }
- else {
- //echo "Saving - validation ok\n";
- $this->status = 'success';
- $spool->save();
- }
- return $sUID;
-
- }
-
-
-
-
-} // end of class
-
-
-
-?>
diff --git a/workflow/engine/classes/class.smtp.rfc-821.php b/workflow/engine/classes/class.smtp.rfc-821.php
deleted file mode 100644
index 8a90ceb18..000000000
--- a/workflow/engine/classes/class.smtp.rfc-821.php
+++ /dev/null
@@ -1,1035 +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
- * @param string $host
- * @param string $port
- * @param string $tval
- * @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
- $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
- # 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 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;
- }
- $this->status = $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;
- }
- $this->status = $this->CRLF . $rply;
- 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 headers. Each header needs to be
- * on a single line followed by a with the message 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 headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg headers
- # and if the first 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
- # 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 headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg 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 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 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 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/workflow/engine/classes/class.spool.php b/workflow/engine/classes/class.spool.php
index f8790ccd2..7d5367240 100755
--- a/workflow/engine/classes/class.spool.php
+++ b/workflow/engine/classes/class.spool.php
@@ -129,9 +129,7 @@ class spoolRun {
* @return none
*/
public function create($aData) {
- G::LoadClass('insert');
- $oInsert = new insert();
- $sUID = $oInsert->db_insert($aData);
+ $sUID = $this->db_insert($aData);
$aData['app_msg_date'] = isset($aData['app_msg_date']) ? $aData['app_msg_date'] : '';
@@ -274,11 +272,14 @@ class spoolRun {
$this->fileData['envelope_to'][] = "$val";
}
}
- } else {
+ } else if($text != '') {
$this->fileData['envelope_to'][] = "$text";
+ } else {
+ $this->fileData['envelope_to'] = Array();
}
- //for cc add by alvaro
- if( false !== (strpos($textcc, ',')) ) {
+
+ //CC
+ if( false !== (strpos($textcc, ',')) ) {
$holdcc = explode(',', $textcc);
foreach( $holdcc as $valcc ) {
@@ -286,11 +287,14 @@ class spoolRun {
$this->fileData['envelope_cc'][] = "$valcc";
}
}
- } else {
+ } else if($textcc != '') {
$this->fileData['envelope_cc'][] = "$textcc";
+ } else {
+ $this->fileData['envelope_cc'] = Array();
}
- //forbcc add by alvaro
- if( false !== (strpos($textbcc, ',')) ) {
+
+ //BCC
+ if( false !== (strpos($textbcc, ',')) ) {
$holdbcc = explode(',', $textbcc);
foreach( $holdbcc as $valbcc ) {
@@ -298,8 +302,10 @@ class spoolRun {
$this->fileData['envelope_bcc'][] = "$valbcc";
}
}
- } else {
+ } else if($textbcc != '') {
$this->fileData['envelope_bcc'][] = "$textbcc";
+ } else {
+ $this->fileData['envelope_bcc'] = Array();
}
@@ -349,9 +355,18 @@ class spoolRun {
break;
case 'PHPMAILER':
G::LoadThirdParty('phpmailer', 'class.phpmailer');
- $oPHPMailer = new PHPMailer();
+ $oPHPMailer = new PHPMailer(true);
$oPHPMailer->Mailer = 'smtp';
$oPHPMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
+
+
+ /**
+ * Posible Options for SMTPSecure are: "", "ssl" or "tls"
+ */
+ if (preg_match('/^(ssl|tls)$/', $this->config['SMTPSecure'])) {
+ $oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
+ }
+
$oPHPMailer->Host = $this->config['MESS_SERVER'];
$oPHPMailer->Port = $this->config['MESS_PORT'];
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
@@ -373,8 +388,9 @@ class spoolRun {
$oPHPMailer->AddAddress($sEmail);
}
}
- //add cc add by alvaro
- foreach( $this->fileData['envelope_cc'] as $sEmail ) {
+
+ //CC
+ foreach( $this->fileData['envelope_cc'] as $sEmail ) {
$evalMail = strpos($sEmail, '<');
if( strpos($sEmail, '<') !== false ) {
@@ -386,8 +402,9 @@ class spoolRun {
$oPHPMailer->AddCC($sEmail);
}
}
- //add bcc add by alvaro
- foreach( $this->fileData['envelope_bcc'] as $sEmail ) {
+
+ //BCC
+ foreach( $this->fileData['envelope_bcc'] as $sEmail ) {
$evalMail = strpos($sEmail, '<');
if( strpos($sEmail, '<') !== false ) {
@@ -491,5 +508,49 @@ class spoolRun {
}
return false;
}
+
+ /**
+ * db_insert
+ *
+ * @param array $db_spool
+ * @return string $sUID;
+ */
+ public function db_insert($db_spool)
+ {
+ $sUID = G::generateUniqueID();
+ $spool = new AppMessage();
+ $spool->setAppMsgUid($sUID);
+ $spool->setMsgUid($db_spool['msg_uid']);
+ $spool->setAppUid($db_spool['app_uid']);
+ $spool->setDelIndex($db_spool['del_index']);
+ $spool->setAppMsgType($db_spool['app_msg_type']);
+ $spool->setAppMsgSubject($db_spool['app_msg_subject']);
+ $spool->setAppMsgFrom($db_spool['app_msg_from']);
+ $spool->setAppMsgTo($db_spool['app_msg_to']);
+ $spool->setAppMsgBody($db_spool['app_msg_body']);
+ $spool->setAppMsgDate(date('Y-m-d H:i:s'));
+ $spool->setAppMsgCc($db_spool['app_msg_cc']);
+ $spool->setAppMsgBcc($db_spool['app_msg_bcc']);
+ $spool->setappMsgAttach($db_spool['app_msg_attach']);
+ $spool->setAppMsgTemplate($db_spool['app_msg_template']);
+ $spool->setAppMsgStatus($db_spool['app_msg_status']);
+ $spool->setAppMsgSendDate(date('Y-m-d H:i:s')); // Add by Ankit
+
+ if(!$spool->validate()) {
+ $errors = $spool->getValidationFailures();
+ $this->status = 'error';
+
+ foreach($errors as $key => $value) {
+ echo "Validation error - " . $value->getMessage($key) . "\n";
+ }
+ }
+ else {
+ //echo "Saving - validation ok\n";
+ $this->status = 'success';
+ $spool->save();
+ }
+ return $sUID;
+
+ }
}
?>
diff --git a/workflow/engine/js/setup/emails.js b/workflow/engine/js/setup/emails.js
index d6196e40e..1e3b581fc 100644
--- a/workflow/engine/js/setup/emails.js
+++ b/workflow/engine/js/setup/emails.js
@@ -81,6 +81,14 @@ function testConnection() {
params += '&auth_required='+ (getField('MESS_RAUTH').checked ? 'yes' : 'no');
params += '&send_test_mail='+ (getField('MESS_TEST_MAIL').checked ? 'yes' : 'no');
params += '&mail_to=' + $('form[MESS_TEST_MAIL_TO]').value;
+
+ if(getField('SMTPSecure][ssl').checked) {
+ params +='&SMTPSecure=ssl';
+ } else if(getField('SMTPSecure][tls').checked) {
+ params +='&SMTPSecure=tls';
+ } else {
+ params +='&SMTPSecure=';
+ }
oPanel = new leimnud.module.panel();
oPanel.options = {
@@ -108,7 +116,7 @@ function testConnection() {
oRPC.callback = function(rpc) {
oPanel.loader.hide();
oPanel.addContent(rpc.xmlhttp.responseText);
- testSMTPHost(1); // execution de init test
+ testSMTPHost(1, params); // execution de init test
}.extend(this);
oRPC.make();
};
@@ -152,19 +160,11 @@ function testConnectionMail() {
};
var resultset = true;
-function testSMTPHost(step) {
+function testSMTPHost(step, params) {
$("test_" + step).style.display = "block";
-
- var requestfile = PROCESS_REQUEST_FILE;
- var params = 'request=testConnection&step=' + step;
- params += '&srv=' + getField('MESS_SERVER').value.trim();
- params += '&port='+ ((getField('MESS_PORT').value.trim() != '') ? getField('MESS_PORT').value : 'default');
- params += '&account=' + getField('MESS_ACCOUNT').value;
- params += '&passwd=' + getField('MESS_PASSWORD').value;
- params += '&auth_required='+ (getField('MESS_RAUTH').checked ? 'yes' : 'no');
- params += '&send_test_mail='+ (getField('MESS_TEST_MAIL').checked ? 'yes' : 'no');
- params += '&mail_to=' + $('form[MESS_TEST_MAIL_TO]').value;
+ var requestfile = PROCESS_REQUEST_FILE;
+ var uri = 'request=testConnection&step=' + step +'&'+ params;
var ajax = AJAX();
ajax.open("POST", requestfile, true);
@@ -193,7 +193,7 @@ function testSMTPHost(step) {
}
}
step += 1;
- testSMTPHost(step);
+ testSMTPHost(step, params);
} catch (e) {
if (resultset) {
$('form[SAVE_CHANGES]').disabled = false;
@@ -207,7 +207,7 @@ function testSMTPHost(step) {
$('status_' + step).innerHTML = " ";
}
}
- ajax.send(params);
+ ajax.send(uri);
}
function cancelTestConnection() {
@@ -256,6 +256,7 @@ function initSet() {
hideRowById('MESS_TEST_MAIL');
hideRowById('MESS_TEST_MAIL_TO');
hideRowById('TEST');
+ hideRowById('SMTPSecure');
hideRowById('SAVE_CHANGES');
$('form[SAVE_CHANGES]').disabled = false;
} else {
diff --git a/workflow/engine/methods/setup/emails.php b/workflow/engine/methods/setup/emails.php
index 6afe58342..68b91bc5b 100644
--- a/workflow/engine/methods/setup/emails.php
+++ b/workflow/engine/methods/setup/emails.php
@@ -59,6 +59,8 @@ else {
}
}
+$aFields['SMTPSecure'] = $aFields['SMTPSecure'] == ''? 'none' : $aFields['SMTPSecure'];
+
$rows[] = array ( 'uid' => 'char', 'name' => 'char', 'age' => 'integer', 'balance' => 'float' );
$rows[] = array ( 'uid' => 'PHPMAILER', 'name' => 'SMTP (PHPMailer)' );
// ending OpenMail support
diff --git a/workflow/engine/methods/setup/emails_Ajax.php b/workflow/engine/methods/setup/emails_Ajax.php
index 4ec8c384b..40c757839 100644
--- a/workflow/engine/methods/setup/emails_Ajax.php
+++ b/workflow/engine/methods/setup/emails_Ajax.php
@@ -60,7 +60,7 @@ switch ($request) {
case 'testConnection':
G::LoadClass('net');
- require_once('classes/class.smtp.rfc-821.php');
+ G::LoadThirdParty('phpmailer', 'class.smtp');
define("SUCCESSFUL", 'SUCCESSFUL');
define("FAILED", 'FAILED');
@@ -77,9 +77,11 @@ switch ($request) {
$auth_required = $_POST['auth_required'];
$send_test_mail = $_POST['send_test_mail'];
$mail_to = $_POST['mail_to'];
+ $SMTPSecure = $_POST['SMTPSecure'];
+ $timeout = 10;
$Server = new NET($srv);
- $oSMTP = new ESMTP;
+ $smtp = new SMTP;
switch ($step) {
case 1:
@@ -92,7 +94,7 @@ switch ($request) {
case 2:
if($port == 0){
- $port = $oSMTP->SMTP_PORT;
+ $port = $smtp->SMTP_PORT;
}
$Server->scannPort($port);
if ($Server->getErrno() == 0) {
@@ -104,37 +106,70 @@ switch ($request) {
#try to connect to host
case 3:
- if($port == 0){
- $resp = $oSMTP->Connect($srv);
+ $hostinfo = array();
+
+ if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) {
+ $host = $hostinfo[1];
+ $port = $hostinfo[2];
} else {
- $resp = $oSMTP->Connect($srv, $port);
+ $host = $srv;
}
- if( !$resp) {
- print(FAILED.','.$oSMTP->error['error']);
+
+ $tls = ($SMTPSecure == 'tls');
+ $ssl = ($SMTPSecure == 'ssl');
+
+ $resp = $smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $timeout);
+ if ($resp) {
+ print(SUCCESSFUL.','.$smtp->status);
} else {
- print(SUCCESSFUL.','.$oSMTP->status);
+ print(FAILED.','.$smtp->error['error']);
}
+
break;
#try login to host
case 4:
- if($auth_required == 'yes'){
- if($port == 0){
- $resp = $oSMTP->Connect($srv);
- } else {
- $resp = $oSMTP->Connect($srv, $port);
- }
- if($resp) {
- $oSMTP->do_debug = false;
- $oSMTP->Hello($srv);
- if( !$oSMTP->Authenticate($user, $passwd) ) {
- print(FAILED.','.$oSMTP->error['error']);
+ if($auth_required == 'yes') {
+ try {
+ $hostinfo = array();
+
+ if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) {
+ $host = $hostinfo[1];
+ $port = $hostinfo[2];
} else {
- print(SUCCESSFUL.','.$oSMTP->status);
+ $host = $srv;
}
- } else {
- print(FAILED.','.$oSMTP->error['error']);
+
+ $tls = ($SMTPSecure == 'tls');
+ $ssl = ($SMTPSecure == 'ssl');
+
+ $resp = $smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $timeout);
+ if ($resp) {
+
+ $hello = $_SERVER['SERVER_NAME'];
+ $smtp->Hello($hello);
+
+ if ($tls) {
+ if (!$smtp->StartTLS()) {
+ // problem with tls
+ }
+
+ //We must resend HELO after tls negotiation
+ $smtp->Hello($hello);
+ }
+
+ if( $smtp->Authenticate($user, $passwd) ) {
+ print(SUCCESSFUL.','.$smtp->status);
+ } else {
+ print(FAILED.','.$smtp->error['error']);
+ }
+
+ } else {
+ print(FAILED.','.$smtp->error['error']);
+ }
+ } catch (Exception $e) {
+ print(FAILED.','.$e->getMessage());
}
} else {
print(SUCCESSFUL.', No authentication required!');
@@ -143,28 +178,33 @@ switch ($request) {
case 5:
if($send_test_mail == 'yes'){
- //print(SUCCESSFUL.',ok');
- $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]';
- $_POST['FROM_EMAIL'] = $user;
+ try {
+ //print(SUCCESSFUL.',ok');
+ $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]';
+ $_POST['FROM_EMAIL'] = $user;
- $_POST['MESS_ENGINE'] = 'PHPMAILER';
- $_POST['MESS_SERVER'] = $srv;
- $_POST['MESS_PORT'] = $port;
- $_POST['MESS_ACCOUNT'] = $user;
- $_POST['MESS_PASSWORD'] = $passwd;
- $_POST['TO'] = $mail_to;
- if($auth_required == 'yes'){
- $_POST['SMTPAuth'] = true;
- } else {
- $_POST['SMTPAuth'] = false;
- }
- $resp = sendTestMail();
+ $_POST['MESS_ENGINE'] = 'PHPMAILER';
+ $_POST['MESS_SERVER'] = $srv;
+ $_POST['MESS_PORT'] = $port;
+ $_POST['MESS_ACCOUNT'] = $user;
+ $_POST['MESS_PASSWORD'] = $passwd;
+ $_POST['TO'] = $mail_to;
+ if($auth_required == 'yes'){
+ $_POST['SMTPAuth'] = true;
+ } else {
+ $_POST['SMTPAuth'] = false;
+ }
+ $resp = sendTestMail();
- if($resp->status){
- print(SUCCESSFUL.','.$resp->msg);
- } else {
- print(FAILED.','.$resp->msg);
+ if($resp->status){
+ print(SUCCESSFUL.','.$resp->msg);
+ } else {
+ print(FAILED.','.$resp->msg);
+ }
+ } catch (Exception $e) {
+ print(FAILED.','.$e->getMessage());
}
+
} else {
print('jump this step');
}
@@ -177,7 +217,7 @@ switch ($request) {
}
function sendTestMail() {
-
+ G::LoadClass("system");
$sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>';
$sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
$msg = G::LoadTranslation('ID_MESS_TEST_BODY');
@@ -194,13 +234,12 @@ function sendTestMail() {
break;
}
- $colosa_msg = "This Business Process is powered by ProcessMaker.";
$sBody = "
$msg [".date('H:i:s')."] - $engine
- This Business Process is powered by ProcessMaker.
+ This Business Process is powered by ProcessMaker ver. ".System::getVersion().". www.processmaker.com