]> git.wh0rd.org - tt-rss.git/blobdiff - classes/ttrssmailer.php
update .gitignore
[tt-rss.git] / classes / ttrssmailer.php
index 1eb9f1d3a2fa14e409db68d2b29664f030345b10..cd10b7cb35a32890296f8082e689575b0b4d62d9 100644 (file)
@@ -7,6 +7,7 @@
 *\r
 */\r
 require_once 'lib/phpmailer/class.phpmailer.php';\r
+require_once 'lib/phpmailer/class.smtp.php';\r
 require_once "config.php";\r
 \r
 class ttrssMailer extends PHPMailer {\r
@@ -17,32 +18,32 @@ class ttrssMailer extends PHPMailer {
                public $CharSet = "UTF-8";\r
                public $PluginDir = "lib/phpmailer/";\r
                public $ContentType = "text/html"; //default email type is HTML\r
-               public $Host;\r
-               public $Port;\r
-               public $SMTPAuth=False;\r
-               public $Username;\r
-               public $Password;\r
 \r
        function __construct() {\r
                $this->SetLanguage("en", "lib/phpmailer/language/");\r
-               //if SMTP_HOST is specified, use SMTP to send mail directly\r
-               if (SMTP_HOST) {\r
-                       $Host = SMTP_HOST;\r
-                       $Mailer = "smtp";\r
-               }\r
-               //if SMTP_PORT is specified, assign it. Otherwise default to port 25\r
-               if(SMTP_PORT){\r
-                       $Port = SMTP_PORT;\r
-               }else{\r
-                       $Port = "25";\r
+\r
+               if (SMTP_SERVER) {\r
+                       $pair = explode(":", SMTP_SERVER, 2);\r
+                       $this->Mailer = "smtp";\r
+\r
+                       $this->Host = $pair[0];\r
+                       $this->Port = $pair[1];\r
+\r
+                       if (!$this->Port) $this->Port = 25;\r
+               } else {\r
+                       $this->Host = '';\r
+                       $this->Port = '';\r
                }\r
 \r
+\r
                //if SMTP_LOGIN is specified, set credentials and enable auth\r
                if(SMTP_LOGIN){\r
-                       $SMTPAuth = true;\r
-                       $Username = SMTP_LOGIN;\r
-                       $Password = SMTP_PASSWORD;\r
+                       $this->SMTPAuth = true;\r
+                       $this->Username = SMTP_LOGIN;\r
+                       $this->Password = SMTP_PASSWORD;\r
                        }\r
+               if(SMTP_SECURE)\r
+                       $this->SMTPSecure = SMTP_SECURE;        \r
        }\r
        /*      @brief a simple mail function to send email using the defaults\r
        *       This will send an HTML email using the configured defaults\r
@@ -59,6 +60,4 @@ class ttrssMailer extends PHPMailer {
                $rc=$this->send();\r
                return $rc;\r
        }\r
-}\r
-\r
-?>\r
+}
\ No newline at end of file