Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Mail.php')
-rw-r--r--core/Mail.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/Mail.php b/core/Mail.php
index 8daf4d2be7..625b067585 100644
--- a/core/Mail.php
+++ b/core/Mail.php
@@ -27,5 +27,48 @@ class Piwik_Mail extends Zend_Mail
public function __construct($charset = 'utf-8')
{
parent::__construct($charset);
+ $this->setTransport();
+ }
+
+
+ public function setTransport()
+ {
+ try
+ {
+ $config = Zend_Registry::get('config')->mail;
+ if ( !empty($config->host)
+ && !empty($config->port)
+ && strcmp($config->transport,"smtp") ==0
+ )
+ {
+ if ( !empty($config->auth->type)
+ || !empty($config->auth->username)
+ || !empty($config->auth->password)
+ )
+ {
+ $config_param = array('auth' => $config->auth->type,
+ 'username' => $config->auth->username,
+ 'password' => $config->auth->password);
+ }
+
+ $smtp_address = $config->host;
+ $smtp_port = $config->port;
+ if(isset($config_param))
+ {
+ $tr = new Zend_Mail_Transport_Smtp("$smtp_address",$config_param);
+ }
+ else
+ {
+ $tr = new Zend_Mail_Transport_Smtp("$smtp_address");
+ }
+ Piwik_Mail::setDefaultTransport($tr);
+ ini_set("smtp_port","$smtp_port");
+ }
+ }
+ catch(Exception $e)
+ {
+ throw new Exception("Configuration SMTP error");
+ }
+
}
}