From ba603c67351452df7092fc49e68ca3691718c96e Mon Sep 17 00:00:00 2001 From: mattpiwik Date: Fri, 23 Jul 2010 19:23:51 +0000 Subject: Fixes issue with Goals API throwing errors when called with lastX git-svn-id: http://dev.piwik.org/svn/trunk@2643 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- core/Mail.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'core/Mail.php') 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"); + } + } } -- cgit v1.2.3