Marius Cramer
2013-11-14 7fe908c50c8dbc5cc05f571dbe11d66141caacd4
interface/lib/classes/ispcmail.inc.php
@@ -34,6 +34,8 @@
 * @package pxFramework
 *
 */
class ispcmail {
    
    /**#@+
@@ -58,6 +60,8 @@
    private $user_agent = 'ISPConfig/3 (Mailer Class)';
    /**#@-*/
    
    /**
     * set the mail charset
     */
@@ -68,31 +72,38 @@
     *
     * @access public
     */
    /**
     * if set to true smtp is used instead of mail() to send emails
     * @see mail
     */
    private $use_smtp = false;
    /**
     * the smtp helo string - use the mail server name here!
     */
    private $smtp_helo = '';
    /**
     * the smtp server to send mails
     */
    private $smtp_host = '';
    /**
     * the smtp port
     */
    private $smtp_port = 25;
    /**
     * if the smtp server needs authentication you can set the smtp user here
     */
    private $smtp_user = '';
    /**
     * if the smtp server needs authentication you can set the smtp password here
     */
    private $smtp_pass = '';
    /**
     * If you want to use tls/ssl specify it here
     */
@@ -101,10 +112,12 @@
     * How many mails should be sent via one single smtp connection
     */
    private $smtp_max_mails = 20;
    /**
     * Should the mail be signed
     */
    private $sign_email = false;
    /**
     * The cert and key to use for email signing
     */
@@ -113,6 +126,7 @@
    private $sign_cert = '';
    private $sign_bundle = '';
    private $_is_signed = false;
    /**
     * get disposition notification
     */
@@ -134,6 +148,8 @@
    public function __destruct() {
        $this->finish();
    }
    
    /**
     * Set option
@@ -197,6 +213,8 @@
        }
    }
    
    /** Detect the helo string if none given
     * 
     */
@@ -207,6 +225,8 @@
        if($this->smtp_helo == '') $this->smtp_helo = 'localhost';
    }
    
    /**
     * Set options
     * 
@@ -215,6 +235,8 @@
    public function setOptions($options) {
        foreach($options as $key => $value) $this->setOption($key, $value);
    }
    
    /**
     * Read a file's contents
@@ -238,6 +260,8 @@
        
        return $content;
    }
    
    /**
     * set smtp connection encryption
@@ -266,6 +290,8 @@
        $this->headers["$header"] = $value;
    }
    
    /**
     * get a mail header value
     *
@@ -279,8 +305,10 @@
        if(strtolower($header) == 'bcc') $header = 'Bcc';
        elseif(strtolower($header) == 'cc') $header = 'Cc';
        elseif(strtolower($header) == 'from') $header = 'From';
        return (isset($this->headers["$header"]) ? $this->headers["$header"] : '');
      return isset($this->headers["$header"]) ? $this->headers["$header"] : '';
    }
    
    /**
     * Set email sender
@@ -300,6 +328,8 @@
        $this->setHeader('From', $header);
    }
    
    /**
     * Set mail subject
     *
@@ -311,6 +341,8 @@
        $this->setHeader('Subject', $subject);
    }
    
    /**
     * Get current mail subject
     *
@@ -320,6 +352,8 @@
    public function getSubject() {
        return $this->headers['Subject'];
    }
    
    /**
     * Set mail content
@@ -334,6 +368,8 @@
        $this->text_part = $text;
        $this->html_part = $html;
    }
    
    /**
     * Read and attach a file
@@ -354,6 +390,8 @@
        $this->attachFile($this->read_File($filename), $display_name);
    }
    
    /**
     * Attach a file
     *
@@ -371,6 +409,8 @@
                           );
        $this->attachments[] = $attachment;
    }
    
    /**
     * @access private
@@ -458,6 +498,8 @@
        }
    }
    
    /**
     * Function to sign an email body
     */
@@ -500,6 +542,8 @@
        return '=' . strtoupper(dechex(ord($matches[1])));
    }
    
    /**
    * Function to encode a header if necessary
    * according to RFC2047
@@ -514,6 +558,8 @@
        
        return $input;
    }
   
   /**
    * Function to encode the subject if necessary
@@ -535,6 +581,8 @@
        
        return $input;
    }
    
    /**
     * @access private
@@ -572,6 +620,8 @@
        return true;
    }
    
    /**
     * @access private
     */
@@ -586,6 +636,8 @@
        $response = @fgets($this->_smtp_conn, 515);
        return true;
    }
    
    /**
     * Send the mail to one or more recipients
@@ -697,6 +749,8 @@
        return $result;
    }
    
    /**
     * Close mail connections
     *
@@ -730,6 +784,7 @@
        
        return;
    }
}
?>