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

Mail.php « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 625b067585915e2744322d40d02be10cd7227e43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
 * @version $Id$
 * 
 * @category Piwik
 * @package Piwik
 */

/**
 * Class for sending mails, for more information see: 
 *
 * @package Piwik
 * @see Zend_Mail, libs/Zend/Mail.php
 * @link http://framework.zend.com/manual/en/zend.mail.html 
 */
class Piwik_Mail extends Zend_Mail
{
	/**
	 * Public constructor, default charset utf-8
	 *
	 * @param string $charset
	 */
	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");
		}
		
	}
}