Project

General

Profile

« Previous | Next » 

Revision 2059

Added by darkviper almost 11 years ago

! update class Wbmailer for use of PHPMailerAutoload

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
01 Jan-2014 Build 2059 Manuela v.d.Decken(DarkViper)
15
! update class Wbmailer for use of PHPMailerAutoload
14 16
01 Jan-2014 Build 2058 Manuela v.d.Decken(DarkViper)
15 17
! change wysiwyg module from filterMediaRel to filterReplaceSysvar
16 18
! change wb::ReplaceAbsoluteMediaUrl from filterMediaRel to filterReplaceSysvar
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.4');
54
if(!defined('REVISION')) define('REVISION', '2058');
54
if(!defined('REVISION')) define('REVISION', '2059');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/framework/class.wbmailer.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25
/* -------------------------------------------------------- */
26
// Must include code to stop this file being accessed directly
27
if(!defined('WB_PATH')) {
28
	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
29
	throw new IllegalFileException();
30
}
31
/* -------------------------------------------------------- */
32
// Include PHPMailer class
33
require_once(WB_PATH."/include/phpmailer/class.phpmailer.php");
34

  
35
class wbmailer extends PHPMailer 
36
{
37
	// new websitebaker mailer class (subset of PHPMailer class)
38
	// setting default values 
39

  
40
	function wbmailer() {
41
		global $database;
42
		// set mailer defaults (PHP mail function)
43
		$db_wbmailer_routine = "phpmail";
44
		$db_wbmailer_smtp_host = "";
45
		$db_wbmailer_default_sendername = "WB Mailer";
46
		$db_server_email = SERVER_EMAIL;
47

  
48
		// get mailer settings from database
49
		// $database = new database();
50
		$query = "SELECT * FROM " .TABLE_PREFIX. "settings";
51
		$results = $database->query($query);
52
		while($setting = $results->fetchRow()) {
53
			if ($setting['name'] == "wbmailer_routine") { $db_wbmailer_routine = $setting['value']; }
54
			if ($setting['name'] == "wbmailer_smtp_host") { $db_wbmailer_smtp_host = $setting['value']; }
55
			if ($setting['name'] == "wbmailer_smtp_auth") { $db_wbmailer_smtp_auth = (bool)$setting['value']; }
56
			if ($setting['name'] == "wbmailer_smtp_username") { $db_wbmailer_smtp_username = $setting['value']; }
57
			if ($setting['name'] == "wbmailer_smtp_password") { $db_wbmailer_smtp_password = $setting['value']; }
58
			if ($setting['name'] == "wbmailer_default_sendername") { $db_wbmailer_default_sendername = $setting['value']; }
59
			if ($setting['name'] == "server_email") { $db_server_email = $setting['value']; }
60
		}
61

  
62
		// set method to send out emails
63
		if($db_wbmailer_routine == "smtp" AND strlen($db_wbmailer_smtp_host) > 5) {
64
			// use SMTP for all outgoing mails send by Website Baker
65
			$this->IsSMTP();                                            
66
			$this->Host = $db_wbmailer_smtp_host;
67
			// check if SMTP authentification is required
68
			if ($db_wbmailer_smtp_auth == "true" && strlen($db_wbmailer_smtp_username) > 1 && strlen($db_wbmailer_smtp_password) > 1) {
69
				// use SMTP authentification
70
				$this->SMTPAuth = true;     	  								// enable SMTP authentification
71
				$this->Username = $db_wbmailer_smtp_username;  	// set SMTP username
72
				$this->Password = $db_wbmailer_smtp_password;	  // set SMTP password
73
			}
74
		} else {
75
			// use PHP mail() function for outgoing mails send by Website Baker
76
			$this->IsMail();
77
		}
78

  
79
		// set language file for PHPMailer error messages
80
		if(defined("LANGUAGE")) {
81
			$this->SetLanguage(strtolower(LANGUAGE),"language");    // english default (also used if file is missing)
82
		}
83

  
84
		// set default charset
85
		if(defined('DEFAULT_CHARSET')) { 
86
			$this->CharSet = DEFAULT_CHARSET; 
87
		} else {
88
			$this->CharSet='utf-8';
89
		}
90

  
91
		// set default sender name
92
		if($this->FromName == 'Root User') {
93
			if(isset($_SESSION['DISPLAY_NAME'])) {
94
				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
95
			} else {
96
				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
97
			}
98
		}
99

  
100
		/* 
101
			some mail provider (lets say mail.com) reject mails send out by foreign mail 
102
			relays but using the providers domain in the from mail address (e.g. myname@mail.com)
103
		*/
104
		$this->From = $db_server_email;                           // FROM MAIL: (server mail)
105

  
106
		// set default mail formats
107
		$this->IsHTML(true);                                        
108
		$this->WordWrap = 80;                                       
109
		$this->Timeout = 30;
110
	}
111
}
112 0

  
branches/2.8.x/wb/framework/class.WbMailer.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25
/* -------------------------------------------------------- */
26
// Must include code to stop this file being accessed directly
27
if(!defined('WB_PATH')) {
28
	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
29
	throw new IllegalFileException();
30
}
31
/* -------------------------------------------------------- */
32
// Include PHPMailer class if needed
33
if (!function_exists('PHPMailerAutoload')) {
34
    require(WbAdaptor::getInstance()->AppPath.'include/phpmailer/PHPMailerAutoload.php');
35
}
36

  
37
class WbMailer extends PHPMailer
38
{
39
	// new websitebaker mailer class (subset of PHPMailer class)
40
	// setting default values 
41

  
42
	function __construct() {
43

  
44
        $oDb = WbDatabase::getInstance();
45
		// set mailer defaults (PHP mail function)
46
		$db_wbmailer_routine = "phpmail";
47
		$db_wbmailer_smtp_host = "";
48
		$db_wbmailer_default_sendername = "WB Mailer";
49
		$db_server_email = SERVER_EMAIL;
50

  
51
		// get mailer settings from database
52
		// $database = new database();
53
		$query = 'SELECT * FROM `'.$oDb->TablePrefix.'settings`';
54
		$oSettingSet = $oDb->doQuery($query);
55
		while($aSettings = $oSettingSet->fetchRow(MYSQL_ASSOC)) {
56
            switch ($aSettings['name']):
57
                case 'wbmailer_routine':
58
                    $db_wbmailer_routine = $aSettings['value']; break;
59
                case 'wbmailer_smtp_host':
60
                    $db_wbmailer_smtp_host = $aSettings['value']; break;
61
                case 'wbmailer_smtp_auth':
62
                    $db_wbmailer_smtp_auth = (bool)$aSettings['value']; break;
63
                case 'wbmailer_smtp_username':
64
                    $db_wbmailer_smtp_username = $aSettings['value']; break;
65
                case 'wbmailer_smtp_password':
66
                    $db_wbmailer_smtp_password = $aSettings['value']; break;
67
                case 'wbmailer_default_sendername':
68
                    $db_wbmailer_default_sendername = $aSettings['value']; break;
69
                case 'server_email':
70
                    $db_server_email = $aSettings['value']; break;
71
                default:
72
                    break;
73
            endswitch;
74
		}
75

  
76
		// set method to send out emails
77
		if($db_wbmailer_routine == "smtp" AND strlen($db_wbmailer_smtp_host) > 5) {
78
			// use SMTP for all outgoing mails send by Website Baker
79
			$this->IsSMTP();                                            
80
			$this->Host = $db_wbmailer_smtp_host;
81
			// check if SMTP authentification is required
82
			if ($db_wbmailer_smtp_auth == "true" && strlen($db_wbmailer_smtp_username) > 1 && strlen($db_wbmailer_smtp_password) > 1) {
83
				// use SMTP authentification
84
				$this->SMTPAuth = true;     	  								// enable SMTP authentification
85
				$this->Username = $db_wbmailer_smtp_username;  	// set SMTP username
86
				$this->Password = $db_wbmailer_smtp_password;	  // set SMTP password
87
			}
88
		} else {
89
			// use PHP mail() function for outgoing mails send by Website Baker
90
			$this->IsMail();
91
		}
92

  
93
		// set language file for PHPMailer error messages
94
		if(defined("LANGUAGE")) {
95
			$this->SetLanguage(strtolower(LANGUAGE),"language");    // english default (also used if file is missing)
96
		}
97

  
98
		// set default charset
99
		if(defined('DEFAULT_CHARSET')) { 
100
			$this->CharSet = DEFAULT_CHARSET; 
101
		} else {
102
			$this->CharSet='utf-8';
103
		}
104

  
105
		// set default sender name
106
		if($this->FromName == 'Root User') {
107
			if(isset($_SESSION['DISPLAY_NAME'])) {
108
				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
109
			} else {
110
				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
111
			}
112
		}
113
		/* 
114
			some mail provider (lets say mail.com) reject mails send out by foreign mail 
115
			relays but using the providers domain in the from mail address (e.g. myname@mail.com)
116
		*/
117
		$this->From = $db_server_email;                           // FROM MAIL: (server mail)
118

  
119
		// set default mail formats
120
		$this->IsHTML(true);                                        
121
		$this->WordWrap = 80;                                       
122
		$this->Timeout = 30;
123
	}
124
}
0 125

  

Also available in: Unified diff